Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Unfortunately, my web hosting plan does not allow public key authentication. Apparently, this method is available to VPS and dedicated server customers only.

I've backed up my Ubuntu 11.10 machine using Deja-Dup and I'm sending the backed up files to my web host using rsync.

I would like to automate this process using a script, but as I am not able to use public key authentication, I am forced to manually copy and paste my (strong) SSH password each time to start the process.

Is there a way round this? If so, how?

share|improve this question
did they really disable pubkey auth, or you just don't have the possibility to use the web control panel to add keys? Can you access the .ssh/authorized_keys file via sftp ? – ithkuil Oct 29 '11 at 12:05
I connected to web space via ssh and executed $ mkdir ~/.ssh/authorized_keys and transferred my public key into this directory using scp. I closed SSH session and logged back in, but I was still prompted for my SSH password. – unpossible Oct 29 '11 at 12:34
@mejpark ~/.ssh/authorized_keys should be a file containing the public keys, not a directory. The recommended method to populate this file is ssh-copy-id, see the link in my answer (or the ssh-copy-id man page). – Gilles Oct 29 '11 at 12:45
up vote 0 down vote accepted

If you need to enter your password, you'll have to do it through expect, because ssh insists on passwords coming from a terminal. Here's an example expect script.

It's possible that the host has disabled public key authentication, but that would require that they deliberately turn it off (with PubkeyAuthentication No in /etc/sshd/sshd_config). There's no technical reason why they'd do it, it would be purely for market segmentation.

I recommend that you first try to make public key authentication work. Follow this procedure to generate and upload a key. Don't hesitate to ask here if something doesn't work; if you tell us what you tried and what error messages you got, we might be able to propose a workaround. If you run into problems, post the sshd configuration (/etc/sshd/sshd_config if the web host is running Ubuntu, maybe another location like /etc/sshd_config if the host is running some other distribution), and the output of ls -ld ~ ~/.ssh; ls -l ~/.ssh.

share|improve this answer
@mejpark Ok, nothing unusual there, other than authorized_keys being a directory. Remove the directory before running ssh-copy-id. – Gilles Oct 29 '11 at 14:18
$ ls -ld ~ ~/.ssh; ls -l ~/.ssh drwx--x--x 18 mejpark mejpark 4096 Oct 29 05:48 /home/mejpark drwxr-xr-x 3 mejpark mejpark 4096 Oct 29 05:48 /home/mejpark/.ssh total 4 drwxr-xr-x 2 mejpark mejpark 4096 Oct 29 05:48 authorized_keys I created .ssh & authorized_keys directories myself. /etc/ssh does not exist on web space. Hostgator rep said public key authentication is not available on my 'baby' plan. Here's link to /etc/ssh/ssh_config file on my machine: – unpossible Oct 29 '11 at 14:23
Running: $ ssh-copy-id -p 2222 <-- file isn't copied to server. No error message is displayed, just a blinking cursor in terminal. – unpossible Oct 29 '11 at 14:41
@mejpark ssh_config is irrelevant, look for a file called sshd_config. It is possible that Hostgator deliberately switched off public key authentication so that they could charge more for this convenient feature. You might still be able to run your own ssh daemon, though. What unix variant is the server running on (run uname -a; lsb_release -a; cat /etc/*version* /etc/*release*)? Also, why did you use -p 2222 (unless you normally connect with ssh -p2222, don't add -p)? – Gilles Oct 29 '11 at 15:22
@mejpark Please try ssh -vvv -p 2222 and show the transcript. There's a good chance that the host is not supporting keys though; this gives you the options of running your own ssh daemon (if the host will allow it), using expect, or paying more for having public key authentication. – Gilles Oct 29 '11 at 15:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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