Setting up passwordless SSH logins is a great way to speed up your workflow when regularly connecting to a remote host like using rsync over ssh. OS X does not include the
ssh-copy-id command and so we will have to find another way. This is how to do it and it doesn't take very long.
Generate a Key
Skip this step if you already have done this previously. you can check by issuing the following command in the terminal:
If you see some thing like:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQAB.....iQ== username@hostname
You already have a key and you can move on to the next step, other wise you can generate a key as follows:
That's it you have generated your key.
Transfer the Public Key to the Remote Host
The first thing you need to do is logon to the remote host and check whether is has a
.ssh directory for the user you are logging in as so in the terminal:
Enter the password and you are logged in as long as the user has an account and you got the password correct. check for the directory by:
If that works you can logout otherwise you need to create the directory:
Now logout using the
exit command and now we can transfer the key we made earlier by:
cat ~/.ssh/id_rsa.pub | ssh user@remotehost 'cat >> ~/.ssh/authorized_keys'
you will need to enter your password again. Now try logging in to the remote server again to confirm it's worked:
If all went well you didn't need to enter a password.
comments powered by Disqus