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
Using the wc command: Using this command:
wc ~/.ssh/authorized_keysI have gotten an output of:
1 3 398 /home/superjohnny/.ssh/authorized_keysChecking if my home directory is encrypted: I have used the following command:
ls -A /home/superjohnnyand I have gotten an output of:
.bash_history .bash_logout .bashrc .cache .profile .ssh .viminfoThere was no .encrypted folder to be found.
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
Using grep command: Using the following command:
grep -v '^[[:space:]]*$' ~/.ssh/authorized_keys | wc -lI get a output of:
1Checking logs messages: Using the following command:
sudo vi /var/log/auth.logI 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 directoryI have not received any other messages in any other days other than April 25th.
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
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.
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_configbut 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)

.authorizedkeysfile is not correct. Don't you have the commandssh-copy-idon your client (windows) box to copy the id? Have you logged into the server (with password) and ranwc ~/.ssh/authorized_keys(output should be 1)? – Anthon Apr 24 '16 at 14:48ssh-copy-id, you can usescp id_rsa.pub user@server:~/.ssh/authorized_keys(assuming you don't already have other public ids in there) – Anthon Apr 24 '16 at 14:52.ssh/authorized_keysfile and.sshfolder. It should be0600and0700respectively. Also checking the verbose log of server, will give you the hint what is wrong. – Jakuje Apr 24 '16 at 14:58.ssh(as that is a directory) and 600 on theauthorized_keysfile in that directory – Anthon Apr 24 '16 at 15:06~which indicates your home directory. The output fromwclooks ok though (one line, three words). You can try to look at/var/log/messageson the server to see if it says something useful. Or startssh -v superjohnny@myipfor extra debugging – Anthon Apr 24 '16 at 15:23git bashyou keep talking about? sounds like nonsensical misunderstanding to me. what are you actually trying to do? ssh from a windows box using putty to an ubuntu box? ssh from the ubuntu box to somewhere else? what exactly doescreated a file which was pretty much id_rsa.pub by using the touch commandmean?touchcan't create key files, that's a job forssh-keygen(on ubuntu) orputtgen(on windows). and forget that nonsense about using awk or anything to {cont} – cas Apr 25 '16 at 23:21There is literally nothing i am doing wrong, you are absolutely wrong about that. – cas Apr 25 '16 at 23:24/etc/ssh/sshd_configso i guess that means you have root access on the ubuntu server. if so, a) did you restartsshdafter changing its config? and b) what does/var/log/auth.logshow when you try to log in? BTW, given your description of how you created~/.ssh/authorized_keysit is possible you messed it up somehow - trygrep -v '^[[:space:]]*$' ~/.ssh/authorized_keys | wc -l. That will count the number of non-empty lines in the file, which should equal the number of keys - so if you've only ever added one key to it, the result should be1. – cas Apr 26 '16 at 08:12grep -v '^[[:space:]]*$' ~/.ssh/authorized_keys | wc -lgives me a result of 1. – questions Apr 26 '16 at 18:58Apr 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 done literally everything, I have looked everywhere for the answer and I find that they jsut give the same answers, no one has really had an ssh key problem as serious as mine... – questions Apr 30 '16 at 01:55/var/log/auth.logis a log file that you are supposed to look in, with e.g.sudo less /var/log/auth.log. – Henrik supports the community Apr 30 '16 at 15:38sudo vi /var/log/auth.log. – questions Apr 30 '16 at 17:00sudo vi? Is there SELinux or some other (please tell us which, if there is) additional security features enabled on the server? – Henrik supports the community Apr 30 '16 at 17:27~var/log/auth.log, the actual syntax of it isvar/log/auth.logwhich I was not doing. If you read the thread you can see the output of what I get when using `sudo vi var/log/auth.log'.There is no other secutrity feature on my server unless you count disabling root login as one in my sshd_config – questions Apr 30 '16 at 18:33sudo /usr/sbin/sshd. – questions Apr 30 '16 at 18:42/usr/sbin/sshd -dgoing into debugging mode on sshd? All my logs that I have are above on method 7 from debugging mode on sshd, sorry if I am not getting what you are saying. – questions May 01 '16 at 01:20/etc/ssh/sshd_config, is this what you were asking Jeff? The following error message I got from it is in the above post. – questions May 01 '16 at 01:32/var/log/auth.logmessage with password disabled to see if it would say anything about ssh keys, I updated method 8 with the var logs of trying to go in by "forcing" it to use ssh keys – questions May 01 '16 at 13:03