SSH is the typical manner most Linux/UNIX administrators use to remotely access and run commands against a Linux/UNIX server or desktop. Occasionally typing a username and password becomes tedious. Having to type your username and password can put a halt to automating processes.

This guide will help in automating SSH login without a password from a Linux/UNIX system to another Linux/UNIX system.


The things you will need before starting:

  • Access to 2 Linux Desktops or Servers.
  • Basic understanding of Linux/UNIX folder structure.


  1. Log in to the first Linux Desktop/Server.
  2. Generate your pubic and private keys.
    user1@server1:~$ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/user1/.ssh/id_rsa):
    [Press Enter Here]
    Enter passphrase (empty for no passphrase): [Press Enter Here]
    Enter same passphrase again: [Press Enter Here]
    Your identification has been saved in /home/user1/.ssh/id_rsa.
    Your public key has been saved in /home/user1/.ssh/
    The key fingerprint is:
    17:0c:23:02:f7:8c:c0:4a:1a:e3:99:ab:30:2b:8f:0f user1@server1
    The key's randomart image is:
    +--[ RSA 2048]----+
    | .o.o . o |
    |o..o = . + |
    |++o . o o |
    |o+ . |
    | . S . |
    |o. . |
    |Eo |
    |+o |
    |ooo |
  3. Copy your public key to the remote server
    user1@server1:~$ ssh-copy-id -i ~/.ssh/ user2@server2
    user2@server2's password:
    Now try logging into the machine, with "ssh 'user2@server2'", and check in:


    to make sure we haven't added extra keys that you weren't expecting.
  4. Finally we need to test our automatic remote login
    user1@server1:~$ ssh user2@server2
    Last login: Tue Mar 4 20:51:33 2014 from
    [Congrats you can login without a password]

If these steps don't work, you can delete the ~/.ssh directory on the remote server and try again. You can now use this password-less ssh login to either shorten your login processes or to help script cronjobs such as rsync.