3 Steps to Perform SSH Login Without Password

It is very easy to perform SSH login to the remote server without prompting a password.

With a help of utilities from OpenSSH package, you can generate authentication keys on your local machine, copy public key to the remote server and add identities to your authentication agent.

Just three simple steps separate you from the possibility of connecting to a remote server without prompting a password.

Step 1: Generate a key pair on the local server

Use ssh-keygen to generate authentication keys for SSH.

$ ssh-keygen

Output:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): 
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
8c:2a:ed:82:98:6d:12:0a:3a:ba:b2:1c:c0:25:be:5b

Step 2: Install your public key on the remote server

Use ssh-copy-id to connect to the remote machine and install your public key by adding it the authorized_keys file.

$ ssh-copy-id -i ~/.ssh/id_rsa.pub UserName@RemoteServer

Output:

UserName@RemoteServer's password: ********
Now try logging into the machine, with "ssh 'username@remoteserver'", and check in:
~/.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.

Step 3: Add a private key to the authentication agent on the local server

Use ssh-add to add identities to the ssh-agent – the authentication agent.

$ ssh-add

Output:

Identity added: /home/user/.ssh/id_rsa (/home/user/.ssh/id_rsa)

Now you can log into the remote server via the SSH protocol without prompting a password.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Start a GUI Application on a Remote Computer using SSH

This article describes how to log into the remote computer (server) using SSH and run a GUI...

SSH Login Slow — Removing Delay

Problem: When I’m trying to log into the remote server via SSH, after I enter the UserName, it...

SSHPass: SSH Login With Password – Command Line

A password-based authentication is often a default way to connect to a remote host over SSH. But...

Signing Failed: Agent Refused Operation [SOLVED]

While attempting to connect to some server over SSH, you may get the error as follows:...

SSH Fingerprint: Get Fingerprint of SSH RSA Key

The fingerprint is a unique sequence of letters and numbers used to identify the SSH RSA key. It...