ansi escape code in output causing send_command to not work
See original GitHub issuedef sshConnection():
file = open('sessionLog.txt', 'w+')
while True:
try:
panIP = input("Panorama IP: ")
fwIP = input("Firewall IP: ")
username = input("Username: ")
password = getpass()
panosConn = ConnectHandler(device_type = "paloalto_panos", host = panIP, username = username, password = password, session_log = 'sessionLog.txt')
break
except (NetMikoAuthenticationException, NetMikoTimeoutException):
print("Authentication Failed")
pass
panosConn.send_command('ssh host '+username+'@'+fwIP+'', expect_string = r'Password')
panosConn.send_command(''+password+'', expect_string = r'>')
panosConn.find_prompt()
panosConn.send_command('set cli pager off')
Traceback (most recent call last): File “C:\pyscripts\netmiko3\lib\site-packages\paramiko\channel.py”, line 699, in recv out = self.in_buffer.read(nbytes, self.timeout) File “C:\pyscripts\netmiko3\lib\site-packages\paramiko\buffered_pipe.py”, line 164, in read raise PipeTimeout() paramiko.buffered_pipe.PipeTimeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “C:\pyscripts\netmiko3\lib\site-packages\netmiko\base_connection.py”, line 541, in _read_channel_expect new_data = self.remote_conn.recv(MAX_BUFFER) File “C:\pyscripts\netmiko3\lib\site-packages\paramiko\channel.py”, line 701, in recv raise socket.timeout() socket.timeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “.\pacPeople.py”, line 85, in <module> main() File “.\pacPeople.py”, line 81, in main panosConn = sshConnection() File “.\pacPeople.py”, line 45, in sshConnection panosConn.send_command(‘ssh host ‘+username+’@’+fwIP+‘’, expect_string = r’Password’) File “C:\pyscripts\netmiko3\lib\site-packages\netmiko\paloalto\paloalto_panos.py”, line 160, in send_command return super().send_command(*args, **kwargs) File “C:\pyscripts\netmiko3\lib\site-packages\netmiko\base_connection.py”, line 1366, in send_command new_data = self.read_until_pattern(pattern=re.escape(cmd)) File “C:\pyscripts\netmiko3\lib\site-packages\netmiko\base_connection.py”, line 618, in read_until_pattern return self._read_channel_expect(*args, **kwargs) File “C:\pyscripts\netmiko3\lib\site-packages\netmiko\base_connection.py”, line 552, in _read_channel_expect “Timed-out reading channel, data not available.” netmiko.ssh_exception.NetmikoTimeoutException: Timed-out reading channel, data not available.
Using expect_string for ssh proxy through another device no longer working in ver 3.0.0 , was previously working in 2.4.2
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (7 by maintainers)
Top GitHub Comments
Netmiko 2.4.2 is different than Netmiko 3.0.0 here (Netmiko 3.0.0 is trying to verify the command echo whereas Netmiko 2.4.2 didn’t)…so that part is expected.
Verifying the command echo fixes a lot of other Netmiko problems.
No only replaced the last octet. The space is present in the log when I run the script in 2.4.2 as well