1

The target server is a relatively clean install of Ubuntu 14.04. I generated a new ssh key using ssh-keygen and added it to my server using ssh-copy-id. I also checked that the public key was in the ~/.ssh/authorized_keys file on the server.

Even still, I am prompted for a password every time I try to ssh into the server.

I noticed something weird however. After I log into my first session using my password, the next concurrent sessions don't ask for a password. They seem to be using the ssh key properly. I've noticed this behaviour on two different clients (Mint OSX).

Samuel Jun
  • 11
  • 1
  • 3

6 Answers6

2

Are you sure your SSH key isn't protected by a password? Try the following:

How do I remove the passphrase for the SSH key without having to create a new key?

If that's not the case, it may just be that ssh is having trouble locating your private key. Try using the -i flag to explicitly point out its location.

ssh -i /path/to/private_key username@yourhost.com
Community
  • 1
  • 1
Martin Konecny
  • 57,827
  • 19
  • 139
  • 159
  • The ssh key was generated with ssh-keygen without a passphrase. – Samuel Jun May 28 '14 at 06:18
  • That command is still producing the same issue. The issue is definitely with the target server since I don't have any issues with other servers. – Samuel Jun May 28 '14 at 06:25
  • 1
    I figured out what the problem was. My home directory on the server is encrypted. I found this helpful [article](https://help.ubuntu.com/community/SSH/OpenSSH/Keys#Troubleshooting). – Samuel Jun May 28 '14 at 06:37
0

Thank you Samuel Jun for the link to help.ubuntu.com - SSH Public Key Login Troubleshooting !

Just a little caveat:

If you copy your authorized keys file outside your encrypted home directory please make sure your root install is encrypted as well (imho Ubuntu still allows for unencrypted root install coupled with encryption of the home directory).

Otherwise this defeats the whole purpose of using encryption in the first place ;)

Tobias F. Meier
  • 321
  • 2
  • 4
0

If this is happening to you on Windows (I'm on Windows 10)

Try running the program that you're trying to connect via ssh to the server as administrator.

For me I was using powershell with scoop to install a couple of things so that I could ssh straight from it. Anyway... I ran PowerShell as admin and tried connecting again and it didn't ask for my password.

BRogers
  • 3,534
  • 4
  • 23
  • 32
0

For LinuxSE

Check the SE context with

% ls -dZ ~user/.ssh

Must contain unconfined_u:object_r:ssh_home_t:s0

If not, that was the problem , as root run

# for i in   ~user/.ssh ~user/.ssh/*
do 
   semanage fcontext -a -t ssh_home_t $i
done
# restorecon -v -R  ~user/.ssh 
RSG
  • 384
  • 3
  • 7
0

It looks like it's related to encryption on your home directory and therefore the authorized_keys file cannot be read.

https://unix.stackexchange.com/a/238570

Community
  • 1
  • 1
A guy
  • 1
0

Make sure your ssh public key was copied to the remote host in the right format. If you open the key file to edit it should read 1 line. Basically, just do ssh-copy-id username@remote. It will take care of the rest.

Keyno
  • 621
  • 5
  • 3