For example if I'm using gitlab and every time I do git pull/push etc. It shows this Username for 'https://gitlab.example.com':
so every time this text is appeared in terminal it should automatically enter the specific input. Also on a broader scale if I put a bunch of commands asking for input in sh file all the respective inputs would be entered automatically by terminal. Git is just for example here, because there exists a way to automate git by adding ssh key. Another example could be automated scp
or ssh
. Thank you for reading.
1 Answer
Of course, switch to Private Key/Public Key authentication.
This guide will explain how to create and add a public key to GitLab, please notice that you'll have to switch your address from https://…
to [email protected]:…
.
Regarding SSH/SCP, all you have to do is to login to the server once using the command ssh-copy-id <user>@<host_address>
(after you've created a private key in the former GitLab guide), instead of actually logging you into the system your public key will be copied and you'll be able to use SSH/SCP without a password.