ㅤㅤㅤ
ㅤㅤㅤ
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ人生的遊戲不在於拿了一副好牌,而在於怎樣去打好壞牌,世上沒有常勝將軍,勇於超越自我者才能得到最後的獎盃
ㅤㅤㅤ
ㅤㅤㅤ
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ
sshpass
ssh登陸不能在命令行中指定密碼,需要用戶交互輸入密碼,sshpass 的出現,解決了這一問題。它允許你用 -p 參數指定明文密碼,然後直接登錄遠程服務器,
它支持密碼從命令行、文件、環境變量中讀取。所以,通過sshpass實現以非交互的形式爲ssh提供密碼
- ubuntu安裝sshpass
sudo apt-get install sshpass
- 查看sshpass相關命令
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
-P prompt Which string should sshpass search for to detect a password prompt
-v Be verbose about what you're doing
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used
- 連接遠程服務器
sshpass -p {password} ssh {username}@{ip} -p {port}