4

Have work on CentOS release 6.3 (Final) system. And try to ssh another machine using sshpass utility like

sshpass -p 'password' ssh user@host

But it give me error like

sshpass: Failed to run command: No such file or directory

So from error i think that sshpass may be not install so have try to install it by yum install sshpass and get following log

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirror.leapswitch.com
 * epel: epel.mirror.net.in
 * extras: mirror.leapswitch.com
 * nux-libreoffice.org-rpms: mirror.li.nux.ro
 * updates: mirror.leapswitch.com
Setting up Install Process
Package sshpass-1.05-1.el6.i686 already installed and latest version
Nothing to do

from above it seems sshpass is already installed.So why it not working?

DennisLi
  • 3,915
  • 6
  • 30
  • 66
Jayesh Bhoi
  • 24,694
  • 15
  • 58
  • 73

1 Answers1

7

Check if your shell knows the locations of sshpass

which sshpass

If it doesnt give any output use find command to find the location of the executable:

find / -name sshpass

If you find the path, you can either use the full path of the executable:

/path/to/sshnpass

Or add the path to the PATH environmental variable, so that your shell can locate it:

export PATH=$PATH:/path/to/

Or the issue might be completely different. sshpass might not be able to find some other dependency. "ssh" client might not be installed. Or your syntax might be wrong:

kiran
  • 525
  • 1
  • 9
  • 26
  • Thanks, using `which sshpass` i got path `/usr/bin/sshpass`.so it works but above path is require to export means its default path. – Jayesh Bhoi Jan 27 '14 at 08:15
  • 2
    You might not have the ssh client installed What is the ouput of "which ssh" ? If its empty you need to install ssh client. – kiran Jan 27 '14 at 08:36
  • output is /usr/bin/ssh. means already installed – Jayesh Bhoi Jan 27 '14 at 08:40
  • Are you typing the command exactly as you mentioned above? Can you try these alternatives: sshpass -p 'password' /usr/bin/ssh user@host sshpass -p 'password' ssh user@localhost Are you using single quotes or double quotes around the password? If your password has special characters, it might force the shell to mistake the arguments. – kiran Jan 27 '14 at 08:47
  • yes command is correct but password contain some crazy character so it cause error. – Jayesh Bhoi Jan 27 '14 at 08:53
  • 1
    For testing just give a normal password.If the issue is with the password, login will fail but you will be able to trace the issue. – kiran Jan 27 '14 at 08:57