Paramiko-expect Timeout Issue
See original GitHub issueHi Team,
I’m using paramiko expect for automating one of my terminal session, however I’m facing an issue with the prompt, please find below the error
>>> import paramiko
>>> import re
>>> from paramiko_expect import SSHClientInteraction
>>>
>>> client = paramiko.SSHClient()
>>> client.load_system_host_keys()
>>> client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
>>> client.connect(hostname='172.19.0.120', username='default', password='default', port =2222)
>>> interact = SSHClientInteraction(client, timeout=5, encoding='utf-8', display=True, buffer_size=100000)
>>> prompt = re.escape('.*$ ')
>>> interact.expect(prompt)
CFS:default@Z18044492 [~]$
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/paramiko/channel.py", line 683, in recv
out = self.in_buffer.read(nbytes, self.timeout)
File "/usr/local/lib/python3.5/dist-packages/paramiko/buffered_pipe.py", line 160, in read
raise PipeTimeout()
paramiko.buffered_pipe.PipeTimeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/paramiko_expect.py", line 144, in expect
current_buffer = self.channel.recv(self.buffer_size)
File "/usr/local/lib/python3.5/dist-packages/paramiko/channel.py", line 685, in recv
raise socket.timeout()
socket.timeout
>>>
Please help me on how to solve this issue?
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
python - paramiko expect timing out - Stack Overflow
I've used regex in there and set it to the exact prompt that it should be seeing and I get the timeout either...
Read more >paramiko-expect - Python Package Health Analysis - Snyk
The python package paramiko-expect was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as...
Read more >Channel - Paramiko documentation
A secure tunnel across an SSH Transport . ... Returns the timeout in seconds (as a float) associated with socket operations, or None...
Read more >pxssh - control an SSH session — Pexpect 4.8 documentation
When the keyword argument timeout is specified as a number, (default: 30), then TIMEOUT will be raised after the value specified has elapsed,...
Read more >python/4284/paramiko-expect/paramiko_expect.py
device. :param client: A Paramiko SSHClient object. :param timeout: The connection timeout in seconds. : ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I found the problem. As a quick fix, you can change default_match_prefix to ‘.*’ in first expect call:
I had the same issue, just changed the prompt on the very first command I send to the remote machine prompt=“AUTO>” interact.send(f"PS1=‘{prompt}’") and keep running