LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Mandriva (https://www.linuxquestions.org/questions/mandriva-30/)
-   -   remove password request during scripted ssh login? (https://www.linuxquestions.org/questions/mandriva-30/remove-password-request-during-scripted-ssh-login-633337/)

babag 04-05-2008 06:55 PM

remove password request during scripted ssh login?
 
can someone please explain or point me to a tutorial
on how to use rsa keys to eliminate the remote computer's
request for a password during an ssh login? i want to use
a script to log in and therefore would like to eliminate
this password request. something mandriva-specific in the
form of a step-by-step walkthrough would be very helpful.
i am able to login now via ssh but would love to be able
to incorporate this into a script. using 2007.1 (spring)
here.

thanks,
BabaG

Brian1 04-05-2008 07:01 PM

Not distro specific but shows the creation of the passphrase, correct permissions on the certain files and directories, and other info. You will need to run the ssh-add command or something similiar and enter the passphrase before it work headless why. Not sure of how to specify the passphrase automatically. I think it would be a bit of security issue if the setup would rquire the passphrase to be present in a plain script to work this way. Maybe someone knows a good way for that.

http://www.suso.org/docs/shell/ssh.sdf

Brian

beadyallen 04-05-2008 07:24 PM

It's dead easy to do:
Code:

ssh-keygen -t rsa -f mykeypair
Just press return when it asks for a password.
It'll create two files, mykeypair (which is your private key, so keep it safe), and mykeypair.pub (the public key that everyone can see). Append the mykeypair.pub file to the <userhomedir>/.ssh/authorized_keys file on the server (if it doesn't exist just create it). Then move your private key (in this case 'mykeypair' to your home/.ssh/id_rsa file, and move the mykeypair.pub file to home/.ssh/id_rsa.pub.

That should be job done. Try and log into the server. ssh will (should) handle to key exchange automatically.

So the complete steps will be:
Code:

ssh-keygen -t rsa -f mykey
scp mykey.pub <username@server>:.ssh/authorized_keys
mv mykey ~/.ssh/id_rsa
mv mykey.pub ~/.ssh/id_rsa.pub

There's plenty of tutorials on the web if you get stick. Google is your friend. It's the same for all distros.
Good luck.

blacky_5251 04-05-2008 07:32 PM

Once you have generated your key, use ssh-copy-id to transfer your public key to the remote server - it is simpler than editing the .authorized_keys file.

babag 04-06-2008 02:25 PM

thanks all! exactly what i needed.

BabaG


All times are GMT -5. The time now is 06:46 AM.