sshpass: 用于非交互的ssh 密码验证
生活随笔
收集整理的這篇文章主要介紹了
sshpass: 用于非交互的ssh 密码验证
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
ssh登陸不能在命令行中指定密碼,也不能以shell中隨處可見的,sshpass 的出現,解決了這一問題。它允許你用 -p 參數指定明文密碼,然后直接登錄遠程服務器。 它支持密碼從命令行,文件,環境變量中讀取
$> sshpass -h Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters -f filename Take password to use from file -d number Use number as file descriptor for getting password -p password Provide password as argument (security unwise) -e Password is passed as env-var "SSHPASS" With no parameters - password will be taken from stdin -h Show help (this screen) -V Print version information At most one of -f, -d, -p or -e should be used
sshpass [-f|-d|-p|-e] [-hV] command parameters 中的 command parameters 和使用交互式密碼驗證的使用方法相同
#從命令行方式傳遞密碼
$> sshpass -p user_password ssh user_name@192.168..1.2 $> sshpass -p user_password scp -P22 192.168.1.2:/home/test/t .
#從文件讀取密碼
$> echo "user_password" > user.passwd $> sshpass -f user.passwd ssh user_name@192.168..1.2
#從環境變量獲取密碼
$> export SSHPASS="user_password" $> sshpass -e ssh user_name@192.168..1.2
對于ssh的第一次登陸,會提示:
“Are you sure you want to continue connecting (yes/no)”,這時用sshpass會不好使,可以在ssh命令后面-o StrictHostKeyChecking=no
來解決。比如說上面的命令,就可以寫作
sshabc@192.168.1.100-o StrictHostKeyChecking=no
PS:
源碼位置:http://sourceforge.net/projects/sshpass/
總結
以上是生活随笔為你收集整理的sshpass: 用于非交互的ssh 密码验证的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: GATK流程--利用Pegasus :
- 下一篇: Nginx配置文件nginx.conf中