#linux #ssh

SSH without a password

Instructions on setting up ssh without a password and debuging possible errors.

Connecting from Client to Server as User on port Port.

  1. Prepare server:

    #First login to server
    ssh -p Port User@Server
    # Correct file permissions
    chmod 700 ~
    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys
    # Get back to Client
    exit
  2. Create a key:

    ssh-keygen -t rsa #Leave the password empty 
  3. Copy the public key to the Server

    ssh-copy-id  -i ~/.ssh/id_rsa -p Port  User@Server
  4. Verify its working:

    ssh -p Port User@Server 

Troubleshooting ssh without a password

  1. Try connecting in verbose mode and watch for errors

    ssh -vvv -p Port User@Server
  2. SSH error : Permissions 0777 for “file” are too open.

    chmod 644 ~/.ssh/*.pub # permissions for public keys
    chmod 600 ~/.ssh/private_key ~/.ssh/{config,known_hosts,authorized_keys} # permissions for private key  & configs
  3. SSH error : Bad owner or permissions on FILE

    chown -R $USER ~/.ssh/

More instructions & information: http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/