简体   繁体   中英

python paramiko

Have installed Paramiko for Python and PyCrypto for Windows 7 machine.

import paramiko    
ssh = paramiko.SSHClient()

Tried the above commands but I keep getting this error msg:

AttributeError: 'module' object has no attribute 'SSHClient'

but this error message goes away if I key in the above commands one line at a time.

Any help?

By chance have you called your file paramiko.py ?

You'll need to name it something else to avoid getting that error.

windows:

1.download PyCrypto: http://www.voidspace.org.uk/python/pycrypto-2.6.1/

2.install PyCrypto,next and next and next

3.pip install paramiko

you can check this command :

import paramiko

device_ip = "your device ip address "
device_username = "your device user name"
device_password = "your device password"


ssh = paramiko.SSHClient()


# Load SSH host keys.
ssh.load_system_host_keys()


# Add SSH host key automatically if needed.
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())


# Connect to device using username/password authentication.
ssh.connect(device_ip, 
            username=device_username, 
            password=device_password,
            look_for_keys=False )



# Banner for ssh login was susseccful
print("SSH Was Successful with python paramiko")


# Close connection.
ssh.close()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM