I am trying to connect to remote MySQL server, which runs on CentOS 6.6 cPanel server.

I am creating tunnel this way:

ssh -L 3306:xxx.xxx.xxx.xxx:3306 [email protected] -p PPPPP

Where xxx.xxx.xxx.xxx is remote server IP address, 3306 ic configured MySQL port, and user is my user name on remote machine, and xxx.xxx.xxx.xxx is IP address of machine which runs MySQL server respectively and PPPPP is non-default SSH port.

I have created id_rsa file with -r-------- permissions, and copied private key generated in cPanel into that file.

As the public/private key pair is created with passphrasse, when trying to connect, shell asks me for passphrase, and output with error:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

What am I doing wrong? My local machine is Debian 8.1 OS.

  • You possibly also need to add the remote host to .ssh/known_hosts
    – DopeGhoti
    Commented Nov 30, 2015 at 21:06
  • Put the public key in the remote user's ~/.ssh/authorized_keys file.
    – D_Bye
    Commented Nov 30, 2015 at 22:34
  • Post verbose log from ssh -vvv PPPPP. It should give you some clue. Also check the server log for authentication errors.
    – Jakuje
    Commented Nov 30, 2015 at 22:40

1 Answer 1


first of all: can you ssh to remote.host ?

if you can, then do:

local$ ssh -L 13306:localhost:3306 [email protected]

put htop to keep-alive connection

remote.host$ htop

on another console:

local$ mysql -P 13306 -h localhost -u root -p
  • why not using -N? Commented Dec 1, 2015 at 4:13
  • don't know, -L works for me! I prefare unix-karate: it is better to know few usefull commands, that really works, than many commands, that I can't apply in real world :)
    – shcherbak
    Commented Dec 1, 2015 at 7:51
  • -N does not need to keep a login session open. I would use autossh anyway. However I could swear it is not what the OP is asking. He seems to be having some problem in the protocol negotiation part. Commented Dec 1, 2015 at 7:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .