I managed to login to my hosting provider manually with this command:

ssh -i /path/to/key-ssh me@mydomain.com

The server then asks for a password, and login succeeds.

Now I want to automate a MySQL backup, so I need to login using a shell script. (to be clear: my provider requires a keypair and a password both to login)

Then I tried to use sshpass:

sshpass -p 'MYPASSWORD' ssh me@mydomain.com

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

Then I tried this:

sshpass -p 'MYPASSWORD' ssh -i /path/to/key-ssh me@mydomain.com

With this the remote server does not respond at all (prompt freezes)

My server runs Debian 8.10 (Jessie)

I am aware of the security risks using sshpass, but I am the only one using this server. I also tried automysqlbackup, but it gives my a headache trying to get it to work over ssl.

Automating a backup over SSH seemed the simplest solution (of which I'm no so sure anymore...)

  • 1
    Are you sure the server asks you for a password? Or are you entering the passphrase for your private key?
    – Panki
    May 14, 2019 at 10:48
  • I think it is the passphrase (sorry I'm no expert...)
    – RadioHat
    May 14, 2019 at 10:52

1 Answer 1


The server isn't asking for your password. What you are typing is the passphrase that protects your private key.

To log in automatically without having to type the passphrase, you first have to remove the passphrase. You do it via the command:

ssh-keygen -p

Be careful to keep your private key in a safe place, though, as without a passphrase anyone could use it.

  • 1
    To add onto this, you can also use ssh-agent and ssh-add to load your key into memory. This way you can keep your passphrase and only need to enter it once.
    – Panki
    May 14, 2019 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.