Results 1 to 5 of 5
Hi All,
I have shell script that connect to remote machine via password less SSH. So I need to do base validation whether password less ssh available or not between ...
- 01-19-2012 #1Just Joined!
- Join Date
- Nov 2010
- Posts
- 23
Validate password-less SSH between two remote machine
Hi All,
I have shell script that connect to remote machine via password less SSH. So I need to do base validation whether password less ssh available or not between two machines. can anyone suggest some way to do this..?

- 01-19-2012 #2
Use PKI, generate an encryption key-pair with 'ssh-keygen' (make sure you use 2048 or bigger keys if possible), and copy the keys to the machine you're connecting from and the server. Then use that key in the login, you can specify the key on the command line, or you can put it into the .ssh directory for the user who the connection is taking place as. There's a more detailed description of the process here.
Linux user #126863 - see http://linuxcounter.net/
- 01-19-2012 #3Just Joined!
- Join Date
- Nov 2010
- Posts
- 23
Thanks for the Quick reply,,
But I already have passwd-less SSH and what I need is shell script to validate it, If I use my script on machine that haven't passwd-less ssh script it self should check and say that you haven't passwd-less SSH between your machines, otherwise it's should prompt "OK you have passwd-less SSH so you can proceed."
- 01-20-2012 #4
You can try using the command:
By disabling password authentication, if you don't have passwordless SSH set up, the command will fail. Here is an example trying to log into my old university's computer lab:Code:ssh -o PasswordAuthentication=no remote.host
Code:$ ssh cabhan@login.ccs.neu.edu cabhan@login.ccs.neu.edu's password: $ ssh -o PasswordAuthentication=no cabhan@login.ccs.neu.edu Permission denied (publickey,password).
DISTRO=Arch
Registered Linux User #388732
- 01-20-2012 #5Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
What cabhan has suggested is exactly what I do. That last piece I add is a remote command to run that always returns success and then evaluate the exit status of the ssh command (which if keys are working is success or '0', and if the keys are not working is failure, or not '0'):
Edit: the failure exit code is not necessarily 1, it is usually 255, but might be some other non-zero numberCode:/usr/bin/ssh -o PasswordAuthentication=no 192.168.1.1 /bin/true if [ $? -eq 0 ]; then echo SSH keys have been set up else echo SSH keys have NOT been set up yet fi
Last edited by atreyu; 01-20-2012 at 05:47 AM. Reason: failure exit status


Reply With Quote