Reputation: 11
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).
Upvotes: 1
Views: 10144
Reputation: 701
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.
Upvotes: 0
Reputation: 1
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
Upvotes: 0
Reputation: 420
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
Upvotes: 0
Reputation: 3604
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.
Upvotes: 0
Reputation: 331
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 ;)
Upvotes: 0
Reputation: 59601
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 [email protected]
Upvotes: 2