2014-01-27 105 views
2

在CentOS版本6.3(最終)系統上工作。並嘗試通過ssh使用sshpass實用另一臺機器就像無法在centOS中運行sshpass命令

sshpass -p 'password' ssh [email protected] 

但它給我的錯誤,如

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

所以從錯誤我認爲sshpass可能無法安裝等都曾嘗試通過yum install sshpass安裝它,得到以下日誌

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 

從上面看來sshpass已經安裝了。所以爲什麼它不工作?

回答

5

檢查,如果你的shell知道sshpass

which sshpass 

的位置。如果它不給任何輸出使用find命令找到可執行文件的位置:

find/-name sshpass 

如果您找到路徑,您可以使用可執行文件的完整路徑:

/path/to/sshnpass 

或者將路徑添加到th e PATH環境變量,以便您的外殼可以找到它:

export PATH=$PATH:/path/to/ 

或者問題可能完全不同。 sshpass可能無法找到其他依賴項。 「ssh」客戶端可能未安裝。或者你的語法可能是wrong

+0

謝謝,使用'which sshpass'我得到了路徑'/usr/bin/sshpass'.so它可以工作,但是上面的路徑需要導出意味着它的默認路徑。 –

+0

您可能沒有安裝ssh客戶端 「which ssh」的輸出是什麼? 如果它爲空,則需要安裝ssh客戶端。 – kiran

+0

輸出是/ usr/bin/ssh。表示已經安裝 –