Forums

SSH Tunnel Issues with Paramiko

Hello,

I am experiencing the same issue than described here: https://www.pythonanywhere.com/forums/topic/34944/ except that I could not resolve them.

In short:

  • The SSHTunnel and connection to MySQL work well on my local computer,
  • However on my remote server, when I try to connect from within a python script using the code suggested in the help pages, I get the error: SSHException: Incompatible ssh peer (no acceptable host key),
  • I have generated both SSH keys using "ssh-keygen -t rsa -b 2048 -E sha512" and "ssh-keygen -t ed25519" and added them to "~/.ssh/authorized_keys" on pythonanywhere,
  • The SSH connection works well from my server (without password) directly from the shell, but I keep getting the error when using it in my python script.
  • I use paramiko=3.0.0

I have followed the troubleshooting steps here: https://github.com/pahaz/sshtunnel/blob/master/Troubleshoot.rst but keep getting the same error.

I don't know if I am missing anything obvious, any help is appreciated.

Solved it by myself :)

There were several versions of paramiko installed in my environment. For some reasons, my python script was importing the old one (2.8.1). Cleaned everything and installed the latest version (3.4.1) and it's now working.

Great, glad to hear you worked it out!