Skip to content

Password-less SSH Login

  • by

An SSH key pair is needed to connect to an SSH server. It is possible to create a password-less key pair so as to bypass the password prompt when you connect to your SSH server. This is handy for when you need to automate some processes through scripting. Follow the instructions below to create a new password-less key pair:

  1. Install OpenSSH. On Ubuntu, you can install OpenSSH by opening your terminal and typing:
    sudo apt-get install openssh-client
  2. Once OpenSSH is installed, stay in the terminal and type:
    ssh-keygen -t dsa -f ~/.ssh/id_dsa
    (Note: For Macs, use “ssh-keygen -t dsa” then press Enter to use the default location)
  3. When prompted for a password, leave blank and hit enter, then enter again to confirm. Your key pair will be created and stored in ~/.ssh/ as [public key] and id_dsa [private key]

Next, you will need to copy the contents of to a file named authorized_keys and transfer the file to the target system you wish to connect to. Follow the instructions below:

  1. Create a new file on the remote server with the following command:
    ssh remoteserver touch ~/.ssh/authorized_keys
  2. Apply the correct permissions:
    ssh remoteserver chmod 600 ~/.ssh/authorized_keys
  3. Transfer the new file to the target server.
    scp ~/.ssh/ remoteserver:~/.ssh/
  4. Copy the contents of to the authorized_keys file:
    ssh remoteserver cat ~/.ssh/ >> ~/.ssh/authorized_keys

You should now be able to connect to your SSH server without having to enter a password.

Ex) scp ~/.ssh/authorized_keys user@targetserver:~/.ssh/