Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errno -8 Servname not supported when using Paramiko, Python

I'm trying to connect to a server via SSH by a Python script. Currently i'm trying out paramiko. I set up a public key between the client and the server so i don't need a password. I'm using the following code at the moment:

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect('192.168.56.102', 'oracle', None, '~/.ssh/id_rsa')
stdin, stdout, stderr = ssh.exec_command('ls')

But when running this I'm getting the error

[Errno -8] Servname not supported for ai_socktype

Any help?

like image 471
Nicholas Avatar asked Aug 13 '26 22:08

Nicholas


1 Answers

You can just specify the parameters. Don't need to add the port number (if it's ok with the default one).

From the definition of connect, your example would look like this:

ssh.connect('192.168.56.102', username='oracle', password=None, key_filename='~/.ssh/id_rsa')
like image 56
perrocontodo Avatar answered Aug 15 '26 13:08

perrocontodo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!