Using SSH on Mac to access Ubuntu server 9.10

First, make sure you can SSH to your server. If you need to install ssh on the Ubuntu server, use:

sudo apt-get install ssh
mkdir ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh

If you are wondering what the touch does, it just creates an empty file if it doesn’t exist.  That way i don’t have to write two sets of instructions based on whether you’ve ever had SSH configured before.  Next we are going to generate our keys and upload them to the server

ssh-keygen -t rsa
scp user@server.com:~/.ssh/authorized_keys ~/.ssh
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys user@server.com:.ssh/

What we are doing is copying the existing authorized_keys file to our local mac to add our key and then uploading it back.  We should now be able to login to our server using our new keys.

ssh user@server.com

The Mac will now prompt you for the password you used to create your ssh key.  Add it to your keychain.  From this point forward, you will no longer be prompted with your password.  Yay!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>