But sometimes typing password repeatedly for establishing a SSH connection with the trusted end machine is quite daunting task.
Let us see how to automate the things in 3 simple steps where we can ssh to "user@host" without asking a password every time. Replace user with the username and host with the remote machine ip-address or hostname. For E.g. john@192.168.245.129
NOTE: Only do this with trusted machines.
- Login to your local machine from which you want to ssh to remote machine. Go to your .ssh folder.
- Check if you have a 'id_rsa.pub' (or 'id_dsa.pub') file in .ssh folder. If not, try below command:
- Run ssh-copy-id
cd ~/.ssh
ssh-keygen -t rsa
To make it simple just keep on pressing the ENTER key a bunch of times, even when it asks for a password.
ssh-copy-id -i id_rsa.pub user@hostIf it asks for remote machine password then provide it so that it can create a security key successfully so that you dont need to remember password everytime.
Its done .. Now you can ssh to user@host without being prompted for password.
I was working for a while on this with no progress but your article saved me....Thank you so much!! :)
ReplyDeleteIt's a life saviour!!
ReplyDeleteI work on more than 30 servers with 11 application users. Now using your article, I configured it and its working absolutely fine. Thanks a lot!!