Skip to content

the thinkpod

where I think out loud

Menu
  • Timeline
Menu

Setting up SSH keys

Posted on July 25, 2011 by milad

Sometimes you work with your remote host so much, that having to enter a password every time becomes a real pain. If that is the case, you should follow with this instructions to set up automatic handshake with your remote host.

First off, you have to have OpenSSH on both the host and your local machine. SSH into your remote host to create the “.ssh” directory in your home folder.

Now we are going to use the SSH Key Generator to create the authorized key.

ssh-keygen -t dsa

You will be prompted to enter a passphrase for this identity key. Choose something hard to break.

Now all you have to do is copy the identity key to the remote host.

scp ~/.ssh/id_dsa.pub myuser@remote.host.com:.ssh/authorized_keys2

Of course, you will replace “myuser@remove.host.com” with your actual remote host’s access information. Now, you will run a simple script that will tell the remote host which identity it should use, and also starts a new shell that will enable you to SSH to the remote host without entering any passwords.

ssh-agent sh -c 'ssh-add < /dev/null && bash'

Now try typing “ssh myuser@remote.host.com” and you will see that you are all set.

2 thoughts on “Setting up SSH keys”

  1. Jeff Harver says:
    November 7, 2012 at 7:42 am

    Instead of the scp line, consider using ssh-copy-id. Also, I think most people use:

    eval `ssh-agent` in their .Xsession or a similarly placed script for their X environment so as to share a common ssh-agent.

    Reply
    1. Milad Naseri says:
      November 7, 2012 at 7:46 am

      Hmmm, cool. Well, at the time of writing this I wasn’t aware of the `ssh-copy-id`. But I ended up knowing about it eventually.

      Thanks for the comment, though. Much appreciated.

      Reply

Leave a Reply to Jeff Harver Cancel reply

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

I’m a tinkerer and engineer. Here, I write about all sorts of things.

Tags

administration algorithms application bash command blog book client clrs code cormen courses Data Structures domain eyeos firefox google google interview google interview series 1 google interview series 2 hello world host interview interview preparation java job learning linux mac phone screen poem Poetry preparation programming Projects repository Review script shell spring synopsis system management user management video windows 7 writing

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2022 the thinkpod | Built using WordPress and Responsive Blogily theme by Superb