Board index Linux SSH

Moderator: chandranjoy

SSH-Passwordless Authentication

Postby chandranjoy » Tue Jan 25, 2011 7:42 pm

SSH Passwordless authentication stpes:

1. Create key
2. Copy key to remote host
3. Login to remote host

Public key authentication allows you to login to a remote host via the SSH
protocol without a password and is more secure than password-based
authentication. Try creating a passwordless connection from
linuxconfig.local to linuxconfig.org using public-key authentication.

Step1: Create key

Press ENTER at every prompt.
# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
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:
b2:ad:a0:80:85:ad:6c:16:bd:1c:e7:63:4f:a0:00:15 [email protected]


linuxconfig#

For added security '''the key itself''' would be protected using a strong
''passphrase''. If a passphrase is used to protect the key, ssh-agent can
be used to cache the passphrase.

Step2: Copy key to remote host

linuxconfig# ssh-copy-id [email protected]
[email protected]'s password:

Now try logging into the machine, with "ssh '[email protected]'", and
check in:
.ssh/authorized_keys


to make sure we haven't added extra keys that you weren't expecting.
[email protected]

Another method to copy key to remote host:

Now use ssh to create a directory ~/.ssh as user b on B. (The directory
may already exist, which is fine):


Finally append a's new public key to
[email protected]:.ssh/authorized_keys and enter [email protected]'s
password one last time:
[email protected]:~> cat .ssh/id_rsa.pub | ssh [email protected]
'cat >> .ssh/authorized_keys'
[email protected]'s password:


From now on you can log into linuxconfig.org as root from
linuxconfig.local as a without password:


now you will root shell prompt of the server 'linuxconfig.org'

Step3: Login to remote host


Note that no password is required.
linuxconfig.local$ ssh [email protected]
Last login: Tue Apr 3 12:47:53 2007 from 192.168.0.39
linuxconfig.org#
chandranjoy
Site Admin
 
Posts: 283
Joined: Fri Oct 23, 2009 11:19 pm

Return to SSH

Who is online

Users browsing this forum: No registered users and 1 guest


cron