Using SSH without a Password

Each time you ssh, scp or sftp to another system, you will be prompted your remote password; this can become tedious. SSH can use public-key authentication instead of password authentication, which means only having to type a password once (when you authenticate your private key for the ssh-agent using your ssh private-key passphrase).

OpenSSH is the de facto standard for connecting to unix hosts.   With few exceptions, all unix (incl. linux and OS X) systems have the ssh tools installed, allowing both outbound and - optionally - inbound ssh connections.

One very useful feature of ssh is the ability to execute ssh, scp and sftp (and programs such rsync) which make use of ssh for secure authentication) commands without having to enter your passwords each time. 


Quick Instructions

  1. Use ssh-keygen -f username to create your public key and password-protected private key.
  2. Add the identity to your ssh-agent
  3. Copy the identity to the remote host

You can then ssh to the remote hosts without entering your password.


Detailed Instructions

Step 1: On local machine

Create your public and private keys. It is important that you enter a strong password to protect this key-pair. You only need to create the key-pair once. 

ssh-keygen -f ~/.ssh/mykeyname

Step 2: Add your private key to local SSH agent

If your ssh-agent is not already running, start it with (those are backticks, NOT single quotes!)

eval `ssh-agent`

Add your identity file to the SSH agent:

ssh-add ~/.ssh/mykeyname

Step 3: Copy your public key to the remote host

Copy your public key to the remote host's authorized_keys file. This is done once for each remote host.

ssh-copy-id me@remotehost

From this point on, you will be able to ssh, scp and sftp to the remote host without being prompted for your remote password.

Add comment

You can add a comment by filling out the form below. Plain text formatting. Web and email addresses are transformed into clickable links. Comments are moderated.