Question:

How to login to other system from my current system in unix ?

by  |  earlier

0 LIKES UnLike

how to login to other system from my current system in unix executing one single shell command or running scripts.

I have to log in as root user to the another machine.

like......

ssh root@hostname

then it asks for password.

how can i use these commands to login in shell scripts?

 Tags:

   Report

1 ANSWERS


  1. Grabbing this from the ssh man page:

    The file ~/.ssh/authorized_keys lists the public keys that are permitted for logging in.  When the user logs in, the ssh program tells the server which key pair it would like to use for authentication.  The client proves that it has access to the private key and the server checks that the corresponding public key is authorized to accept the account.

    The user creates his/her key pair by running ssh-keygen(1).  This stores the private key in ~/.ssh/identity (protocol 1), ~/.ssh/id_dsa (protocol 2 DSA), or ~/.ssh/id_rsa (protocol 2 RSA) and stores the public key in ~/.ssh/identity.pub (protocol 1), ~/.ssh/id_dsa.pub (protocol 2 DSA), or ~/.ssh/id_rsa.pub (protocol 2 RSA) in the user’s home directory.  The user should then copy the public key to ~/.ssh/authorized_keys in his/her home directory on the remote machine.  The authorized_keys file corresponds to the conventional ~/.rhosts file, and has one key per line, though the lines can be very long.  After this, the user can log in without giving the password.

    Got all that? The meat of that is that you generate a public key for yourself on the LOCAL machine with "ssh-keygen", you add the contents of "~/.ssh/identity.pub" (don't use identity! that's your private key) to the other machine's ~/.ssh/authorized_keys file. Now do the same on the other host. When you're done each host will have the public key of the other host in its authorized_keys file:

    LOCAL -> authorized_keys=(REMOTE PUBLIC KEY)

    REMOTE -> authorized_keys=(LOCAL PUBLIC KEY)

    LOCAL and REMOTE are purely labels here, they could be A and B or whatever. Check out this website for a nifty trick on how to add your keys to the other file, but be sure you run ssh-keygen to actually produce the keys.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.