Wednesday, November 2, 2011

Creating a Trusted SSH Connection

Sometimes I have a need to script out an ssh session and do not want to be prompted for a password when the connection is established.  So, I have to create a trusted connection between the 2 boxes.  I am going to assume that I am logged in as root, but you can do this as any user.  Just replace root with the username in the directions below.  In order to do this, the following steps should be taken:


  1. On the local host, go to the following directory /root/.ssh/
  2. Run the following command in order to generate a file that contains the key you will need: ssh-keygen -t ds
    • When prompted for what file to save the key, you can just leave the default which is what we will use, /root/.ssh/id_dsa
    • When prompted for a passphrase, you can just leave blank.
  3. Now go into the new file generated id_dsa.pub and copy the contents.  
  4. Log into the remote host.
  5. Go to the directory /root/.ssh/.
  6. Edit or create the file authorized_keys.  You will paste the contents from id_dsa.pub that you copied from the local machine in there.
That is all there is to it.  When you ssh from the local machine to the remote machine now, it will go straight into it without prompting you for a password.  


No comments:

Post a Comment