NOTE: This is not a duplicate to the popular question. Why am I still getting a password prompt with ssh with public key authentication?

I had an original post but I did not get much answers helping me. I will try and explain my 3 day problem in thorough detail.

How I added the id_rsa.pub ssh key into my Ubuntu server:

What I did was I created it through my normal windows 10 computer through a git scm terminal (can be found here https://git-for-windows.github.io/). I had to use git because a normal cmd prompt in windows 10 would not work. I generated it through ssh-keygen which generated 2 keys for me, one id_rsa and one id_rsa.pub.

After that I went on my putty terminal, logged into my remote server and created a .ssh directory in my /home/superjohnny folder (my sudo user) and I made a folder within the .ssh folder called authorized_keys. I copied and pasted my id_rsa.pub key into the authorized_keys folder and then later added 600 permissions on it by doing chmod 600 .ssh/authorized_keys.

Once I did that I went into my /etc/ssh/sshd_config and added the following into my config settings:

    RSAAuthentication yes
    PubkeyAuthentication yes
    AuthorizedKeysFile %h/.ssh/authorized_keys

All these lines are also uncommented. I then did sudo service ssh restart and then I still get a password prompt when trying to log in. This has been going on for a week

The methods I have tried: I have used both threads that were discussed above to try and get an answer and I have also used my google search extensively. Here are the methods that I have used.

1. Putting the key on one line I have tried using in the git scm terminal on my computer the following command:

    cat ~/.ssh/id_rsa.pub | awk '{print}' ORS=' '

The command above supposedly doesn't do anything because the key was already on one line when I copied it, it's just that the terminal couldn't fit the key. Here is the thread I have used to find that command. https://stackoverflow.com/questions/36818651/how-to-display-output-on-single-line

  1. Using the wc command: Using this command:

    wc ~/.ssh/authorized_keys
    

    I have gotten an output of:

      1   3 398 /home/superjohnny/.ssh/authorized_keys
    
  2. Checking if my home directory is encrypted: I have used the following command:

    ls -A /home/superjohnny
    

    and I have gotten an output of:

    .bash_history  .bash_logout  .bashrc  .cache  .profile  .ssh  .viminfo
    

    There was no .encrypted folder to be found.

  3. Going on debugging mode to check for extra information: While on a session I did the following command:

    ssh -v superjohnny@myip
    

and got this as a result:

    debug1: Found key in /home/superjohnny/.ssh/known_hosts:1
    debug1: ssh_ecdsa_verify: signature correct
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey,password
    debug1: Next authentication method: publickey
    debug1: Trying private key: /home/superjohnny/.ssh/id_rsa
    debug1: Trying private key: /home/superjohnny/.ssh/id_dsa
    debug1: Trying private key: /home/superjohnny/.ssh/id_ecdsa
    debug1: Trying private key: /home/superjohnny/.ssh/id_ed25519
    debug1: Next authentication method: password

This must be a hint to something but looking through the web for awhile I couldn't find much about this problem, only found a thread about it here: https://askubuntu.com/questions/54670/passwordless-ssh-not-working And this thead just tells me to recreate the key file which I have done numerous times

  1. Using grep command: Using the following command:

    grep -v '^[[:space:]]*$' ~/.ssh/authorized_keys | wc -l
    

    I get a output of:

    1
    
  2. Checking logs messages: Using the following command:

    sudo vi /var/log/auth.log
    

    I have received a lot of errors all on the same day, the same exact error but I will only post a bit of it:

     Apr 25 04:14:01 ramnode CRON[977]: pam_unix(cron:session): session    closed for user root
    Apr 25 04:54:01 ramnode CRON[1076]: pam_env(cron:session): Unable to open env file: /etc/default/locale: No such file or directory
    

    I have not received any other messages in any other days other than April 25th.

  3. Going on debugging mode with sshd:

Doing

    /usr/sbin/sshd -d

gives me an output of:

    debug1: sshd version OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
    debug1: could not open key file '/etc/ssh/ssh_host_rsa_key': Permission denied
    Could not load host key: /etc/ssh/ssh_host_rsa_key
    debug1: could not open key file '/etc/ssh/ssh_host_dsa_key': Permission denied
    Could not load host key: /etc/ssh/ssh_host_dsa_key
    debug1: could not open key file '/etc/ssh/ssh_host_ecdsa_key': Permission denied
    Could not load host key: /etc/ssh/ssh_host_ecdsa_key
    debug1: could not open key file '/etc/ssh/ssh_host_ed25519_key': Permission denied
    Could not load host key: /etc/ssh/ssh_host_ed25519_key
    debug1: setgroups() failed: Operation not permitted
    debug1: rexec_argv[0]='/usr/sbin/sshd'
    debug1: rexec_argv[1]='-d'

However adding sudo in front of the command likeso:

    sudo /usr/sbin/sshd -d

gives me an output of:

    debug1: sshd version OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
    debug1: key_parse_private2: missing begin marker
    debug1: read PEM private key done: type RSA
    debug1: private host key: #0 type 1 RSA
    debug1: key_parse_private2: missing begin marker
    debug1: read PEM private key done: type DSA
    debug1: private host key: #1 type 2 DSA
    debug1: key_parse_private2: missing begin marker
    debug1: read PEM private key done: type ECDSA
    debug1: private host key: #2 type 3 ECDSA
    debug1: private host key: #3 type 4 ED25519
    debug1: rexec_argv[0]='/usr/sbin/sshd'
    debug1: rexec_argv[1]='-d'
    Set /proc/self/oom_score_adj from -800 to -1000
  1. Trying to see if home directory permissions had to be smaller: I tried to change the home directory permissions because I thought that the permissions might not allowed for the .ssh directory to work. I used the following command:

    chmod 755 ~/
    

    but that did nothing at all when I restarted my terminal with sudo service ssh restart and then when I logged back into another terminal it still prompted me with a password.

  2. Trying to disable Password I have tried to disable the password and not logging out of my secession so I can change it if it doesn't work. I did this by going into the

    /etc/ssh/sshd_config 
    

    but when I went on to a new terminal screen I get the following error:

    Disconnected: No supported authentication methods avaliable(server sent: publickey
    

The /var/log/auth.log messages that I had when trying to log in with password disabled so the system would try and use ssh keys was this:

    May  1 09:02:00 ramnode sshd[16905]: error: Received disconnect from 64.121.77.168: 14: No supported authentication methods available [preauth]
    May  1 09:02:13 ramnode sudo: superjohnny : TTY=pts/1 ; PWD=/home/superjohnny ; USER=root ; COMMAND=/usr/bin/vi /var/log/auth.log
    May  1 09:02:13 ramnode sudo: pam_unix(sudo:session): session opened for user root by superjohnny(uid=0)

closed as off-topic by Jeff Schaller, slm May 6 '16 at 3:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Jeff Schaller, slm
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    THERE IS NO REASON TO SHOUT. We have bold and italics for emphasis. – Anthon Apr 24 '16 at 14:43
  • 2
    You have at least wrong permissions on .ssh/authorized_keys file and .ssh folder. It should be 0600 and 0700 respectively. Also checking the verbose log of server, will give you the hint what is wrong. – Jakuje Apr 24 '16 at 14:58
  • 2
    Looks like your /etc/ssh/ssh_config was overwritten with something else. Can you show its contents (the first 10 lines)? – ott-- Apr 24 '16 at 18:03
  • 2
    You are correct that your question is not a duplicate. You are wrong about the reason. A dupe is still a dupe if the underlying problem is the same, even if the Linux distro is different and even if the older question is for FreeBSD or OS X or AIX or Solaris or some other non-Linux unix. In other words, the fact that you're on Ubuntu and the other question is on Centos doesn't automatically prevent your question from being a duplicate. – cas Apr 25 '16 at 2:12
  • 1
    Have you tried putting the remote sshd into debug mode ? It may have a reason for denying the key auth. – Jeff Schaller Apr 30 '16 at 14:43
up vote 1 down vote accepted

I found the answer with the help of a very good friend who was very patient with my problem. The problem was that the putty client was not set up to accept my key, I had the authorized key files and all the permissions right it's just that this one little problem was not noticed until now.

In my putty client I did not put in a private key into my secession and I originally had thought that the remote server would just look into my files and check to see if the key was there. I was wrong and my friend had told me that this would be a huge security risk and said that the private key had to be put into putty likeso:

enter image description here

Thank you guys for also helping too, I learned a lot along the way with this problem.

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