Login Remote System ssh Without Password | Linux Redhat Rhel5

First we need to create rsa Key
1)#ssh-keygen -t rsa
-t rsa it will create the RSA(Rivest, Shamir and Adleman) Key
it will creat the key with file name "id_rsa.pub" under the current user Home Directory.
If it is root mean /root/.ssh/id_rsa.pub
if it is redhat mean /home/redhat/.ssh/id_rsa.pub
ssh-copy-id it will install public key to the remote machine
then copy the id to the remote system, For first time it will ask the password.
Next it will not ask the password.
#ssy-copy-id -i /root/.ssh/id_rsa.pub remoteuser@remoteip
2)#ssh-copy-id -i /root/.ssh/id_rsa.pub hpc@151.8.27.214
While Copy the key it will ask the Password For enter the Login credentials.
AFter copy completed.
3)then try to login from the remote sytem. It doesn't ask any of the password.

Even though SSH HOST offer RSA public Key if it is ask password

we should maintain $HOME/.ssh folder with 700 permission
NOTE: if .ssh folder has full permission even though it supply rsa public key, it will ask the password like following,
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password
to avoid these we've to maintain right permission #chmod -R 700 .ssh
$HOME/.ssh/id_rsa - it should able to access only by the user.

Post a Comment

1 Comments

  1. #!/usr/bin/expect -f

    if { [llength $argv] < 3 } {
    send "Usage: ssh2 \n"
    exit;
    }

    set host [lrange $argv 0 0]
    set user [lrange $argv 1 1]
    set pass [lrange $argv 2 2]
    set supass [lrange $argv 3 3]

    set timeout -1

    spawn ssh $user@$host
    match_max 100000

    expect {
    "*yes/no*" {
    send -- "yes\r"
    exp_continue
    }
    "*?assword:*" {
    send -- "$pass\r"
    }
    }
    interact

    ReplyDelete