需求:通过python 连接生产服务器,发送命令到服务器执行。
环境:本地开发 -- jumpserver(跳板机)-- 目标服务器(114.xxx.xxx.144)
我的代码:
gateway_session = SSHSession(host=LINUX_PRO['hostname'],
username='xxxx',
pkey=private_key,
port=LINUX_PRO['hostport'],
password='').open()
remote_session = gateway_session.get_remote_session(host='114.xx.xx.144',
username='root',
password='',
port=2xx2
)
运行提示错误:jumpssh.exception.ConnectionError: Unable to connect to '114.xxx.xxx.144:25552' with user 'root': Authentication failed.
提供思路:平时pem 文件登录跳板机,显示如下:
我直接输入:Opt or IP or Hostname>: tn_139
便可以登录上目标服务器了。也就是登录目标服务器,没有再使用密码这一说。
然而如上代码里,在python 连接目标服务器时,我也并没有提供 passport,但是报出认证失败。。
疑问:
- 是因为我未提供正确的密码?
- 还是跳板机可以设置目标服务器,禁止使用密码连接??