Issue connecting to ASA
See original GitHub issueHello,
I am having an issue connecting to an ASA using netmiko. This is my first thing I have built in python so it might be obvious but I don’t have enough experience to really understand what I am missing. Also at this point I am not doing much I just wanted to get the connection working before I actually ran all the commands I am going to be running against the devices. The connection to switches and routers works fine it is just the ASA, which I can putty into with no issue. I don’t know if this is something that would effect it but I am using an ACS server attached to LDAP for authentication and the enable password is blank.
This is the code that I use to get the error further below:
import netmiko
import csv
import getpass
username = input('ACS username: ')
password = getpass.getpass(prompt='ACS Password: ', stream=None)
enable_password = getpass.getpass(prompt='Enable Password: ', stream=None)
shift = input('Enter shift: ')
basedir = "Y:\Get_ALL_Configs"
version = []
with open('E:\Scripts\Devices.csv') as csvfile:
reader = csv.DictReader(csvfile)
data = [r for r in reader]
for device in data:
d1 = device
d1.update({'username': username, 'password': password})
def FirewallInfo( firewall ):
firewall_connect = netmiko.ConnectHandler(**firewall)
firewall_command = firewall_connect.send_command("sh ver")
version.append(firewall_command)
firewall_connect.disconnect()
def SwitchInfo( switch ):
switch_connect = netmiko.ConnectHandler(**switch)
switch_command = switch_connect.send_command("sh ver")
version.append(switch_command)
switch_connect.disconnect()
for device in data:
if device['device_type'] == 'cisco_asa':
print(device['ip'])
device.update({'secret': enable_password, 'port': 22})
FirewallInfo(device)
elif device['device_type'] == 'cisco_ios':
print(device['ip'])
SwitchInfo(device)
else:
print('Device %s is not recognized' % device['ip'])
print(version)
Error: Traceback (most recent call last): File “C:\Program Files\Python36\lib\site-packages\paramiko\channel.py”, line 683, in recv out = self.in_buffer.read(nbytes, self.timeout) File “C:\Program Files\Python36\lib\site-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 “C:\Program Files\Python36\lib\site-packages\netmiko-2.2.2-py3.6.egg\netmiko\base_connection.py”, line 442, in _read_channel_expect new_data = self.remote_conn.recv(MAX_BUFFER) File “C:\Program Files\Python36\lib\site-packages\paramiko\channel.py”, line 685, in recv raise socket.timeout() socket.timeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “E:/Scripts/Test_GetDevice.py”, line 37, in <module> FirewallInfo(device) File “E:/Scripts/Test_GetDevice.py”, line 22, in FirewallInfo firewall_connect = netmiko.ConnectHandler(**firewall) File “C:\Program Files\Python36\lib\site-packages\netmiko-2.2.2-py3.6.egg\netmiko\ssh_dispatcher.py”, line 190, in ConnectHandler return ConnectionClass(*args, **kwargs) File “C:\Program Files\Python36\lib\site-packages\netmiko-2.2.2-py3.6.egg\netmiko\base_connection.py”, line 246, in init self.session_preparation() File “C:\Program Files\Python36\lib\site-packages\netmiko-2.2.2-py3.6.egg\netmiko\cisco\cisco_asa_ssh.py”, line 19, in session_preparation self.disable_paging(command=“terminal pager 0”) File “C:\Program Files\Python36\lib\site-packages\netmiko-2.2.2-py3.6.egg\netmiko\base_connection.py”, line 863, in disable_paging output = self.read_until_prompt() File “C:\Program Files\Python36\lib\site-packages\netmiko-2.2.2-py3.6.egg\netmiko\base_connection.py”, line 510, in read_until_prompt return self._read_channel_expect(*args, **kwargs) File “C:\Program Files\Python36\lib\site-packages\netmiko-2.2.2-py3.6.egg\netmiko\base_connection.py”, line 450, in _read_channel_expect raise NetMikoTimeoutException(“Timed-out reading channel, data not available.”) netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data not available.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
I will be working on this the next few days trying to add a non-empty secret and then retesting. I will let you know whether it fixes it for me.
Thank you so much Kirk!
I’ll look into the subclass.
Get Outlook for Androidhttps://aka.ms/ghei36
From: Kirk Byers notifications@github.com Sent: Wednesday, December 12, 2018 1:37:35 PM To: ktbyers/netmiko Cc: cdzr; Mention Subject: Re: [ktbyers/netmiko] Issue connecting to ASA (#940)
@cdzrhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcdzr&data=02|01||5f8f2769a04a41f6856708d660694478|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|636802402560842359&sdata=6PDGlw8efXGkUbpw29hMbDXMk0TY16l12tLB3y5LnLs%3D&reserved=0 Nope that is not supported in Netmiko (at least directly). We support straight .enable() call using an enable() secret.
We also support asa_login() using username and password that you used to SSH to device.
I guess you could try to subclass the CiscoAsaSSH and then over-write the asa_login method. You would have to tell Netmiko to then use this class instead of the default one for the ASA.
Regards, Kirk
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fktbyers%2Fnetmiko%2Fissues%2F940%23issuecomment-446716331&data=02|01||5f8f2769a04a41f6856708d660694478|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|636802402560842359&sdata=SKsIwrKNoH6%2BWQgWaoPPtCEb%2B0De0sHZm5r%2FyKiK1qk%3D&reserved=0, or mute the threadhttps://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAgcPK--oo-Da4Ztjp8M0rSrLzcrYJTF-ks5u4Vr_gaJpZM4WVRrJ&data=02|01||5f8f2769a04a41f6856708d660694478|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|636802402560842359&sdata=Ln5SpnktLhq48LRJ4MB0r5umeiEEGiTRFHEIFOCuZhQ%3D&reserved=0.