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 user@host


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 root@linuxconfig.org
root@linuxconfig.org's password:

Now try logging into the machine, with "ssh 'root@linuxconfig.org'", and
check in:
.ssh/authorized_keys


to make sure we haven't added extra keys that you weren't expecting.
linuxconfig.local$root@linuxconfig.org

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):
root@linuxconfig.org:~> ssh root@linuxconfig.org mkdir -p .ssh
root@linuxconfig.org's password:


Finally append a's new public key to
root@linuxconfig.org:.ssh/authorized_keys and enter root@linuxconfig.org's
password one last time:
root@linuxconfig.local:~> cat .ssh/id_rsa.pub | ssh root@linuxconfig.org
'cat >> .ssh/authorized_keys'
root@linuxconfig.org's password:


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

root@linuxconfig.local:~> ssh root@linuxconfig.org hostname

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 root@linuxconfig.org
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