For some reason I'm unable to SSH from my Ubuntu 15.10 machine to a remote server using a private key if I run ssh without sudo.
Server side config is fine. I have tested the private key from my Windows machine and from a CentOS box and both can use it.
If I put the private key in ~/.ssh authentication fails and I'm prompted for a password. However, if I put the same private key in /root/.ssh and use sudo ssh I can connect as normal.
Works: sudo ssh user@host.com -vvv
Doesn't Work: ssh user@host.com -vvv
I did notice this in the verbose SSH output.
Without Sudo: Offering RSA public key: /home/matt/.ssh/id_rsa
With Sudo: Trying private key: /root/.ssh/id_rsa
Prior to that line output is the same.
Using the root .ssh directory isn't the end of the world but this doesn't seem correct.
Does anyone know why it's not working with the ssh key in my user's home directory?
Output when running ssh -vv user@host:
OpenSSH_6.9p1 Ubuntu-2ubuntu0.1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to gitlab.git.ho.me [192.168.1.155] port 22.
debug1: Connection established.
debug1: identity file /home/matt/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/matt/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/matt/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/matt/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/matt/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/matt/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/matt/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/matt/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9p1 Ubuntu-2ubuntu0.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4+deb7u3
debug1: match: OpenSSH_6.0
---
*Source: Ask Ubuntu Archive (CC BY-SA 4.0)*