Configure ssh for no password (password-less SSH login)

configure ssh for no password

How execute login without password with ssh.

[A]–(SSH login to)–>[B]

#1 On local computer [A] (your PC)
(command ssh-keygen)

you have to generate two keys :

a) run in Terminal (on computer [a]) :

$ ssh-keygen
 Generating public/private rsa key pair.
 Enter file in which to save the key (/home/<user>/.ssh/id_rsa):identity
 Enter passphrase (empty for no passphrase):
 Enter same passphrase again:
 Your identification has been saved in identity.
 Your public key has been saved in identity.pub.
 The key fingerprint is: ....

Note in red :

  • Just press enter when ask : Enter passphrase…
  • leave name identity (or chose a new name)

b) Run in Terminal (on computer [a]) :

$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/<user>/.ssh/iddsa): identity2
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in iddsa.
Your public key has been saved in identity2.pub.
The key fingerprint is: ....

Note in red :

  • Just press enter when ask : Enter passphrase…
  • leave name identity2 (or chose a new name)

#2 On remote computer [B] (remote server) and [A]
a) move in <user> home

$cd ~
$mkdir .ssh
$chmod 700 .ssh

b) On local computer [A]

$cd ~/.ssh
$scp *.pub <USER>@<IP-REMOTE-B>:.ssh/

c) On remote computer [B]

$cd ~/.ssh
$ls -ltra
drwx------ 3 **** **** 4096 Apr  2 16:14 ..
-rw-r--r-- 1 **** **** 2839 Apr  2 17:00 known_hosts
-rw-r--r-- 1 **** ****  611 Apr  2 17:20 identity2.pub
-rw-r--r-- 1 **** ****  403 Apr  2 17:20 identity.pub

$cat ./identity.pub >> authorized_keys
$cat ./identity2.pub >> authorized_keys2

$chmod 700 authorized_keys*

rm identity.pub identity2.pub

now we can login without password : ssh <USER>@<IP-REMOTE-B>

Posts