Tag Archives: SSHException: Error reading SSH protocol banner

SSHException: Error reading SSH protocol banner

Knowledge map advanced must read: read how large-scale map data efficient storage and retrieval>>>

When I used SSH to remotely connect the server of another machine, I made an error. The error is as follows. At first, I thought there was something wrong with my own code. Later, I took a local look and found that there was no problem with my running. I began to find out the reason according to the error

At first, I saw this article on the Forum blog and tried to read it. It means that your self.banner’s default source code time setting is only 15 seconds. Let me modify the source code in transform.py and then install paramiko offline. After trying, I still reported the above error. After trying, I still didn’t use it. The netizen’s technical posts are not all practical. It’s up to me. The problems here can be eliminated, Continue to find the reason and check the sshd port

paramikoE xception:ErrorreadingSSHprotocolbanner

File”/usr/local/lib/python3.5/site-packages/paramiko/transport.py”,line2044,in_ check_ Banner
buf = self. Packer. ReadLine (timeout)
Modify: self. Banner_ timeout=15
self.banner_ Timeout = 300
Download: https://src.fedoraproject.org/repo/pkgs/python-paramiko/ I chose: paramiko-1.15.2. Tar. GZ
tar-xzvfparamiko-1.15.2. Tar. GZ
cdparamiko-1.15.2cdparakimo
vimtransport.py: S/self.banner_ The timeout is changed to: 300 (press n next)
CD..

python3setup. Pybuild

python3setup. Pyinstall

3. Query sshd port configuration

SSH localhost shows that the port is 36000

ssh:connecttohostlocalhostport36000 :Noroutetohost

To confirm whether the configuration has been changed, check the sshd configuration:

vi /etc/ssh/sshd_ conf

A face of black line, you know the port default here is 22, was changed to 36000

Re modify the code to solve the problem:

def run():


ip = '192.168.110.136'
port = 36000

pwd = 'admin'
user = 'root'
client = SshConnect(ip, user, pwd, port)
res = client.exe_cmd('pwd&&cd /usr/local&&pwd') # type should be str
log.info(res)