1

I've generated an SSH key on MacOS using the ssh-keygen command, standard issue.

I've tried to get the key to work both with DBeaver and using SSHTunnelForwarder in Python. Both fail with a garden variety message of Auth fail.

I read here that I needed to generate a PEM key which I did so now my key starts with

-----BEGIN RSA PRIVATE KEY-----

instead of

-----BEGIN OPENSSH PRIVATE KEY-----

but this had no effect. The odd thing is, I can log into the server using key-auth on the terminal with both key formats.

When I use SSHTunnelForwarder:

# Have tried both OpenSSH and RSA (pem) formats
mypkey = paramiko.RSAKey.from_private_key_file('/Users/some_user/.ssh/id_rsa')

with SSHTunnelForwarder(
          ("host", 22),
          ssh_username="some_user",
          ssh_pkey=mypkey,
          remote_bind_address=("localhost", 3306)
     ) as server:
    with connect(
        host="127.0.0.1",
        user="some_user",
        password='some_password'
     ) as connection:
        print(connection)
[2021-05-11 15:43:55,476] {transport.py:1819} INFO - Connected (version 2.0, client OpenSSH_8.5)
[2021-05-11 15:43:55,801] {transport.py:1819} INFO - Authentication (publickey) failed.

If I use password auth I get in no problem.

seve
  • 159
  • 12
  • You're sure you've added the public key to `authorized_hosts` on your host? Can you `ssh` in from a command line (`ssh -i ~/.ssh/id_rsa some_user@host`)? – Tim Roberts May 12 '21 at 00:35
  • yes, with both the OpenSSH and RSA variants of the key. The authorized_keys file on the host has the public key present. – seve May 12 '21 at 00:37

0 Answers0