我试图连接建立与主机机器的ssh连接。 这里是我的代码:
def make_connection_paramiko(Username, Password):
ssh = paramiko.SSHClient()
hostname = "username@hobbes.cs.ucsb.edu"
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.load_host_keys(os.path.expanduser(os.path.join("~", ".ssh", "known_hosts")))
try:
ssh.connect(hostname, port = 22, username = 'username', password = 'password')
except paramiko.AuthenticationException:
print "Login failed! %s\t%s" %(username, password)
except socket.timeout:
print "Socket connection failed"
#print str(value) +"\t"+ message
else:
print "Login Successful! %s\t%s" %(username, password)
ssh.close()
但由于某些原因,我不断收到以下错误:
Traceback (most recent call last):
File "pass_crack.py", line 56, in <module>
begin_cracking(wordlist, username)
File "pass_crack.py", line 45, in begin_cracking
make_connection_paramiko(username, "hello")
File "pass_crack.py", line 29, in make_connection_paramiko
ssh.connect(hostname, port = 3600, username = 'xxxxxxx', password = 'xxxxxx')
File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 282, in connect
for (family, socktype, proto, canonname, sockaddr) in socket.getaddrinfo(hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM):
socket.error: [Errno 2] No such file or directory
我想使用的paramiko与蟒蛇进行连接,而我使用Ubuntu 13.04。 我不知道什么是错的,当我试图使用相同的值作为主机名,用户名和密码,使用连接pxssh
的连接工作,所以为什么不与它的paramiko工作?
提前致谢