paramiko 中的 get_allowed_auths() 用于身份验证类型

发布于 2024-08-01 13:56:07 字数 240 浏览 2 评论 0原文

我正在尝试从 Python 中运行的 SSH 服务器获取支持的身份验证类型/方法。

我在 Paramiko 的 ServerInterface 类中找到了这个方法 get_allowed_auths() ,但我无法理解它是否可以在简单的类似客户端的代码片段中使用(我正在编写仅在这个任务中完成的东西)。

任何人都可以建议我一些带有示例的链接,其他分发文档吗? 也许还有其他想法可以做到这一点?

谢谢。

I am trying to get supported authentication types/methods from a running SSH server in Python.

I found this method get_allowed_auths() in the ServerInterface class in Paramiko but I can't understand if it is usable in a simple client-like snippet of code (I am writing something that accomplish in ONLY this task).

Anyone can suggest me some links with examples, other the distribution documentation?
Maybe any other ideas to do this?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梨涡 2024-08-08 13:56:07

您可以尝试不使用身份验证进行身份验证,这应该总是失败,但服务器将发回可以继续的身份验证类型。 paramiko.Transport 提供了一个 auth_none() 方法来执行此操作。

import paramiko
import socket

s = socket.socket()
s.connect(('localhost', 22))
t = paramiko.Transport(s)
t.connect()

try:
    t.auth_none('')
except paramiko.BadAuthenticationType, err:
    print err.allowed_types

You can try to authenticate using no authentication, which should always fail, but the server will then send back the auth types that can continue. There is an auth_none() method provided by paramiko.Transport to do this.

import paramiko
import socket

s = socket.socket()
s.connect(('localhost', 22))
t = paramiko.Transport(s)
t.connect()

try:
    t.auth_none('')
except paramiko.BadAuthenticationType, err:
    print err.allowed_types
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文