Search code examples
pythonsshparamikoattributeerror

Paramiko / Netmiko SSH Error - 'Channel' object has no attribute 'update_environment_variables'


I am trying to set up an SSH connection to a Cisco router using paramiko but it is giving the following error:

  File "/Library/Python/2.7/site-packages/paramiko/client.py", line 467, in invoke_shell
chan.update_environment_variables(environment or {})
AttributeError: 'Channel' object has no attribute 'update_environment_variables'

Here is the code I am using:

def init_connect():
global tun
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

print "\n\nAttempting connection to ", device_ip, " via SSH"
ssh.connect(device_ip,username=username,password=password,timeout=5)
print "Connection established."

tun = ssh.invoke_shell()
output = tun.recv(1000)

print output

Solution

  • This is a bug with paramiko 2.1. Refer https://github.com/paramiko/paramiko/issues/859

    Till this is fixed. You can use older version of paramiko. Use below command to downgrade.

    pip install paramiko==2.0.2