0

I have Python 3 and Linux (Ubuntu), I have done an SSH connection to a server creating a rsa public key, since the other computer has been enabled to only accept RSA keys. I was only able to do it by setting the options in the config file: PubkeyAcceptedKeyTypes +ssh-rsa and HostKeyAlgorithms=+ssh-dss.

Now, I want to do the same but using python and paramiko, but i haven't been able to do it. I have tried doing a regular connection like:

ssh = paramiko.SSHClient()


ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())


key = paramiko.RSAKey.from_private_key_file(key_filename)

ssh.connect(hostname=hostname, username=username, pkey=key)

But I get: AuthenticationException: Authentication failed.

The final part of the log is:

DEBUG:paramiko.transport:userauth is OK
DEBUG:paramiko.transport:Finalizing pubkey algorithm for key of type 'ssh-rsa'
DEBUG:paramiko.transport:Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
DEBUG:paramiko.transport:Server did not send a server-sig-algs list; defaulting to our first preferred algo ('rsa-sha2-512')
DEBUG:paramiko.transport:NOTE: you may use the 'disabled_algorithms' SSHClient/Transport init kwarg to disable that or other algorithms if your server does not support them!
INFO:paramiko.transport:Authentication (publickey) failed.

I think it fail because I don't specify the accepted public key configurations, but I haven't found any other way that works

0 Answers0