0

My goal is to be able to ssh into localhost on my remote linux machine (Ubuntu 12.04 LTS x64).

I have a private key that on my local Windows that I use in putty to access that remote machine. On the remote machine, ~/.ssh/authorized_keys contains the corresponding public key.

In puttygen, I loaded this private key and used "Export OpenSSH key". Puttygen then warns me "Are you sure you want to save this key without a passphrase to protect it?". The content of that key is then stored in ~/.ssh/id_rsa in the remote machine.

However, when I try to execute ssh localhost on the remote machine, I am asked for a password. Just pressing enter yields

me@host:~/.ssh$ ssh localhost
Enter passphrase for key '/home/me/.ssh/id_rsa':
Permission denied (publickey,hostbased).

File / folder permissions are as such:

me@host:~/.ssh$ ls -lsa
total 20
4 drwx------  2 me sudo 4096 Aug  6 09:43 .
4 drwxr-xr-x 11 me sudo 4096 Aug  6 09:38 ..
4 -rw-------  1 me sudo  381 Feb  1  2014 authorized_keys
4 -rw-------  1 me sudo 1589 Aug  6 09:38 id_rsa
4 -rw-r--r--  1 me sudo 1106 Aug  6 08:44 known_hosts

What can I do to be able to password-less ssh into localhost?

5
  • That should work. Can you 1. Stop SSH daemon 2. Run /usr/sbin/sshd -d 3. Try to log on 4. Post the output?
    – mtak
    Aug 6, 2014 at 8:03
  • I have no physical access to this machine (virtual server in a cloud). Won't stopping the ssh daemon block me out completely?
    – helm
    Aug 6, 2014 at 8:06
  • Stopping SSH will not close the existing sessions. Just make sure you don't close the PuTTY window ;) To be sure you can run sshd on an alternative port with /usr/sbin/sshd -d -p 2222 and run the ssh client with ssh -p2222 localhost
    – mtak
    Aug 6, 2014 at 8:07
  • Thanks @mtak, this is good to know. However, upon reading the log, I copied my private key again just to be save. I don't see anything I did differently, but it works now. Strange, but good enough for now.
    – helm
    Aug 6, 2014 at 8:22
  • This might be a bit off topic but can I ask what the purpose of ssh localhost is? Aren't you already logged into localhost on the remote machine? I think what you've done may be a security issue too because id_rsa is your private key for logging into the server, but it sounds like you've also saved this key ON the server. Private keys id_rsa are like real keys, Public keys id_rsa.pub are like the padlocks they open. ~/.ssh/authorized_keys is like a door with multiple padlocks. You have to unlock one of them to login as that user. ;-) Apr 9, 2019 at 10:50

0

You must log in to answer this question.

Browse other questions tagged .