[英]pxssh- Could not login to the server with special characters in the password
When I try to login to a remote server with special characters in the password, it throws a 'Password Refused'
error. 当我尝试使用密码中的特殊字符登录到远程服务器时,它将引发
'Password Refused'
错误。 However, it works for the password without special characters. 但是,它适用于不带特殊字符的密码。
My code: 我的代码:
import pxssh
s = pxssh.pxssh()
s.login('mylabserver4.com', 'testuser', 'Tes123P@ss')
But, I am getting 'Password refused'
error even though the password is correct. 但是,即使密码正确,我也会收到
'Password refused'
错误。
How do I get the code to accept special characters? 如何获得接受特殊字符的代码?
Try escaping special character @
with \\
尝试使用
\\
转义特殊字符@
s.login('mylabserver4.com', 'testuser', 'Tes123P\\@ss')
Ideal way should be to ask for the user prompt as per the documentation as well: 理想的方式应该是也根据文档要求用户提示:
http://pexpect.readthedocs.io/en/stable/api/pxssh.html#pexpect.pxssh.pxssh
http://pexpect.readthedocs.io/zh-CN/stable/api/pxssh.html#pexpect.pxssh.pxssh
from pexpect import pxssh
import getpass
try:
s = pxssh.pxssh()
hostname = raw_input('hostname: ')
username = raw_input('username: ')
password = getpass.getpass('password: ')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.