Tuesday 16 December 2014

sshpass command in linux


Posted: May 2, 2014 in Uncategorized
0
ssh login with password instead of waiting for password prompt:
Possible with sshpass.
Check if the server is installed with sshpass by running below command
which sshpass.
If no path found, then install with
#yum install sshpass
if no luck, then download rpm and install it.
sshpass rpm download link:
http://dl.fedoraproject.org/pub/epel/6/x86_64/sshpass-1.05-1.el6.x86_64.rpm
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/sshpass-1.05-1.el6.x86_64.rpm
# rpm -ivh sshpass-1.05-1.el6.x86_64.rpm
# which sshpass
/usr/bin/sshpass
Now log onto server with password in single command which ignores user prompt for password
sshpass -p ‘leo$123′ ssh root@172.15.25.228
If we want to run any command on other server from one server to prevent log on to other server.
ssh root@172.15.25.228 “netstat -tunlp”
Prompts for password
With password in a single command:
sshpass -p ‘leo$123′ ssh root@172.15.25.228 “netstat -tunlp”

No comments:

Post a Comment