[英]Fetch prelogin banner from SSH server using Paramiko without authenticating
[英]Is there a way using Paramiko and Python to get the banner of the SSH server you connected to?
有沒有辦法使用 Paramiko 和 Python 來獲取您嘗試連接的 SSH 服務器的橫幅?
我正在處理許多機器的超安全服務器設置過程,密碼是通過預定義的密鑰生成的,該密鑰與 SSH 橫幅一起打印出來。 我可以訪問為我提供密碼的實用程序,但我需要橫幅中的文本才能實際生成初始密碼。
看起來這不是一個功能。 好在我要求它並且非常棒的開發人員將它放入......
https://github.com/paramiko/paramiko/issues/273
# !/usr/bin/python
import paramiko
def grab_banner(ip_address, port):
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
client.connect(ip_address, port=port, username='username', password='bad-password-on-purpose')
except:
return client._transport.get_banner()
if __name__ == '__main__':
print grab_banner('192.168.1.26', 22)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.