您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python-Pxssh-尝试登录到远程服务器时出现密码拒绝错误

Python-Pxssh-尝试登录到远程服务器时出现密码拒绝错误

这个错误是因为ssh是lock.so打开终端并执行该命令

xxxx@toad:~$ rm .ssh/kNown_hosts

删除kNown_hosts

一个选择是您在Windows中登录意味着检查命令提示符。如果您尝试在Windows中登录,则意味着要使用pexpect

child = pexpect.spawn('ssh tiger@172.16.0.190 -p 8888')
child.logfile = open("/tmp/mylog", "w")
print child.before
child.expect('.*Are you sure you want to continue connecting (yes/no)?')
child.sendline("yes")

child.expect(".*assword:")
child.sendline("tiger\r")
child.expect('Press any key to continue...')
child.send('\r')
child.expect('C:\Users\.*>')
child.sendline('dir')
child.prompt('C:\Users\.*>')

pxssh使用shell提示符来同步远程主机的输出

为了使其更加健壮,它将shell提示设置为比$或#更独特的内容。这应该适用于大多数Borne / Bash或Csh样式的shell。 http://www.pythonforbeginners.com/code-snippets-source-code/ssh-connection- with-python/

python 2022/1/1 18:52:22 有375人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶