代码之家  ›  专栏  ›  技术社区  ›  Om Sao

python如何使用jumpssh连接无密码

  •  0
  • Om Sao  · 技术社区  · 5 年前

    这可以通过使用 jumpssh 代码如下:

    >>> from jumpssh import SSHSession
    
    # establish ssh connection between your local machine and the jump server
    >>> gateway_session = SSHSession('gateway.example.com',
    ...                              'my_user_1', password='my_password_1').open()
    
    # from jump server, establish connection with a remote server
    >>> remote_session = gateway_session.get_remote_session('remote.example.com', 'my_user_2', password='my_password_2')
    

    remote.example.com 使用密码。

    我找不到一个办法,我们怎么能联系到 remote.example.com 无需简单密码 ssh remote.example.com gateway.example.com

    当我传递命令时: ssh gateway.example.com 使用jumpssh,我得到错误:

    身份验证失败,需要用户名和密码

    或者可以使用Python中的其他模块吗?

    1 回复  |  直到 5 年前
        1
  •  0
  •   Nullman    5 年前

    一般来说,ssh需要某种形式的身份验证,证书(密钥)或名称/密码 根据 api reference private_key_file 作为参数之一,默认为 ~/.ssh/
    read up on it ,但简而言之,您需要创建一个证书(密钥)对,将公共证书(密钥)对放在您尝试连接的服务器上,将私有证书(密钥)对放在 ~/.ssh文件/ 或将位置传递给 jumpssh 使用 私钥文件 参数