已为 Python 安装了 Paramiko,为 Windows 7 机器安装了 PyCrypto。
import paramiko
ssh = paramiko.SSHClient()
尝试了上述命令,但我不断收到此错误消息:
AttributeError: 'module' object has no attribute 'SSHClient'
但是如果我一次输入上述命令一行,这个错误消息就会消失。
有什么帮助吗?
碰巧你打电话给你的文件paramiko.py
吗?
您需要将其命名为其他名称以避免出现该错误。
你可以检查这个命令:
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()
视窗:
1.下载PyCrypto:<a href="http://www.voidspace.org.uk/python/pycrypto-2.6.1/" rel="nofollow noreferrer">http://www.voidspace.org.uk/蟒蛇/pycrypto-2.6.1/
2.安装PyCrypto,next and next and next
3.pip安装paramiko