I am trying to connect setup a ssh connection with a host machine. Here is my code:
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()
But for some reason I keep on getting the following error:
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
I am trying to connect using paramiko with python, and I am using Ubuntu 13.04. I am not sure what is wrong, when I have tried to connect using the same values for the hostname, username, and password using pxssh
the connection works, so why doesn't it work with paramiko?
Thanks in advance