Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Netmiko timing out after sending command
#1
The purpose of my script is to connect to our FTD (Firepower threat defence) and run a packet capture then ftp it to a host

The problem:

The script works as it it transfers the file, but it then times out and I can't figure out why, I would leave it but I need to continue the script to analyse the caputre.

Any help apprecaited

Here is the output from the FTD if I were typing the commands:

Output:
> file copy 192.168.1.10 myusername / capture.pcap Enter password for myusername@192.168.1.10:<myPassword> Copying capture.pcap Copy successful. Copying capture.pcap Copy successful. Copying capture.pcap Copy successful. >
This is an excerpt from my code:
#--snip--
output += connection.send_command(
    'file copy 192.168.1.10 myusername / capture.pcap',
    expect_string=r'password'
)
print('sending ftp password')
output += connection.send_command(
    'c7bernet',
    expect_string=r'>'
)
#--snip--
And the error message:
Error:
Traceback (most recent call last): File "C:\Users\awarren\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko\channel.py", line 699, in recv out = self.in_buffer.read(nbytes, self.timeout) File "C:\Users\awarren\AppData\Local\Programs\Python\Python37\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:\Users\awarren\AppData\Local\Programs\Python\Python37\lib\site-packages\netmiko\base_connection.py", line 541, in _read_channel_expect new_data = self.remote_conn.recv(MAX_BUFFER) File "C:\Users\awarren\AppData\Local\Programs\Python\Python37\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 "fmcCaptureSendVdi.py", line 35, in <module> expect_string=r'>' File "C:\Users\awarren\AppData\Local\Programs\Python\Python37\lib\site-packages\netmiko\base_connection.py", line 1366, in send_command new_data = self.read_until_pattern(pattern=re.escape(cmd)) File "C:\Users\awarren\AppData\Local\Programs\Python\Python37\lib\site-packages\netmiko\base_connection.py", line 618, in read_until_pattern return self._read_channel_expect(*args, **kwargs) File "C:\Users\awarren\AppData\Local\Programs\Python\Python37\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.

Sorry, I solved my own problem.. I used this bit of code from here: Netmiko Github

I think it explains itself but basically looks at the output from the command slightly differently - if anyone can elaborate I'd be grateful :)

#--snip--
command = "file copy 192.168.1.10 myusername / capture.pcap"
print(connection.find_prompt())
output = connection.send_command_timing(command)
if "password" in output:
    output += connection.send_command_timing(
        "<password>", strip_prompt=False, strip_command=False
    )
#--snip--
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Connect to device without paramiko/netmiko modules kang18 3 224 Jun-05-2020, 10:54 AM
Last Post: Larz60+
  Netmiko Program ssh from the Jumpssh ( host -> Jumphost -> Network Device matya0403 2 265 May-29-2020, 10:27 AM
Last Post: matya0403
  netmiko: print out specific line matches with 'Cisco IOS Software' in sh ver output sabrina 0 214 Apr-20-2020, 05:52 AM
Last Post: sabrina
  netmiko connecting to arista devices. dan1962 0 489 Feb-07-2020, 09:23 PM
Last Post: dan1962

Forum Jump:


Users browsing this thread: 1 Guest(s)