溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Linux下如何使用sshpass繞過SSH密碼驗證

發(fā)布時間:2022-01-26 11:04:47 來源:億速云 閱讀:372 作者:小新 欄目:開發(fā)技術

這篇文章將為大家詳細講解有關Linux下如何使用sshpass繞過SSH密碼驗證,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

ssh 直接使用 TTY 訪問,以確保密碼是用戶鍵盤輸入的。 sshpass 在專門的 tty 中運行 ssh,以誤導 ssh 相信它是從用戶接收到的密碼。

Linux下如何使用sshpass繞過SSH密碼驗證

1. 安裝

?  Desktop sudo yum install sshpass
[sudo] password for xuyaowen:
Last metadata expiration check: 0:04:22 ago on Mon 02 Jul 2018 11:25:32 AM CST.
Package sshpass-1.06-5.fc28.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!

檢查是否安裝

[root@yaowenxu Desktop]# rpm -qa sshpasssshpass-1.06-5.fc28.x86_64

2. 查看 sshpass 命令幫助, 也可以使用 man sshpass

View Code

[root@yaowenxu Desktop]# sshpassUsage: 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

3. 使用密碼驗證登錄

?  ~ sshpass -p 123 ssh root@10.66.65.15

4. ssh 第一次登錄提示問題使用:

ssh -o StrictHostKeyChecking=no

來解決

?  Desktop sshpass  -p 123 ssh -o StrictHostKeyChecking=no root@10.66.8.142
Warning: Permanently added '10.66.8.142' (ECDSA) to the list of known hosts.
Last login: Mon Jul  2 10:51:29 2018

5. 優(yōu)缺點

優(yōu)點: 快速,便捷

缺點: 密碼明文暴露,可以使用 history 命令查找到


關于“Linux下如何使用sshpass繞過SSH密碼驗證”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI