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)
Similar Posts:
- [Solved] The paramiko module failed to upload the file: paramiko.ssh_exception.SSHException: Channel closed.
- Paramiko Error: Garbage packet received [How to Solve]
- java.net.NoRouteToHostException: Cannot assign requested address
- The problem of requirementparseerror in using Python paramiko package
- [Solved] Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-*
- Execute the Jmeter Script Error: .org.apache.http.conn.httphostconnectexception: XXXX failed: unable to specify the solution of the requested address (Connect failed)
- Module not founderror: no module named ‘paramiko’ in Python 3.7.2
- SSH Connection Error: no matching host key type found. Their offer: ssh-dss [Solved]
- [Solved] SSH is disconnected as soon as it is connected
- Debian pip3 ImportError: cannot import name ‘IncompleteRead’ [How to Solve]