有没有办法使用 Paramiko 和 Python 来获取您连接的 SSH 服务器的横幅? [英] Is there a way using Paramiko and Python to get the banner of the SSH server you connected to?

查看:48
本文介绍了有没有办法使用 Paramiko 和 Python 来获取您连接的 SSH 服务器的横幅?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用 Paramiko 和 Python 来获取您尝试连接的 SSH 服务器的横幅?

Is there a way using Paramiko and Python to get the banner of the SSH server you attempt to connect to?

我正在为许多机器处理一个超安全的服务器设置过程,密码是通过预定义的密钥生成的,该密钥与 SSH 横幅一起打印出来.我可以访问提供密码的实用程序,但我需要横幅中的文本才能实际生成初始密码.

I am dealing with an ultra secure server setup process for many machines and the passwords are generated via a predefined cipher key which get's printed out at with the SSH banner. I have access to the utility that will give me the password, but I need the text in the banner to actually generate the initial password.

推荐答案

看起来这不是一个功能.好在我要求它,非常棒的开发人员把它放进去了......
https://github.com/paramiko/paramiko/issues/273

Looks like this wasn't a feature. Good thing I requested it and the totally awesome developers put it in...
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)

这篇关于有没有办法使用 Paramiko 和 Python 来获取您连接的 SSH 服务器的横幅?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆