I am attempting to setup a private git server on my local network and I cannot for the life of me figure out what I am doing wrong. I can't seem to get ssh authentication via private key working for the git user.
I have run ssh-keygen
on the client to create an rsa pub/private key. I have created the ~/.ssh/authorized_keys
file on the server. I have copied the contents of id_rsa.pub
over to the authorized_keys
file on the server, by using scp
to transfer the file to the server and then cat id_rsa.pub > ~/.ssh/authorized_keys
on the server to ensure there were no copy errors. I have restarted the ssh daemon.
On the client, the ~/.ssh
folder has permissions 700, and the ~/.ssh/id_rsa
file has permissions 600. On the server, the ~/.ssh
folder has permissions 700, and the ~/.ssh/authorized_keys
file has permissions 600.
My server's ssh config at /etc/ssh/sshd_config
has the following uncommented lines
Include /etc/ssh/sshd_config.d/*.conf
KbdInteractiveAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
PasswordAuthentication yes
Match User git
PasswordAuthentication no
PubkeyAuthentication yes
The /etc/ssh/sshd_config.d/
folder is empty. The server is running Ubuntu 22.04.1 LTS
. The server's ssh version is OpenSSH_8.9p1 Ubuntu-3ubuntu0.1, OpenSSL 3.0.2 15 Mar 2022
Upon attempting to ssh [email protected]
I am greeted with the following
Permission denied (publickey).
What am I missing? I've looked at guides. I've made sure I am copying the key over accurately. I am honestly stumped because I have inserted public keys into the authorized_keys
file before on a server with ssh already setup, and it's worked. If I set the sshd config to allow PasswordAuthentication
then I can login as the git user fine with the password I have set on it. I do not understand why the public private key auth is not working.
Output of ssh [email protected] -vvv
https://pastebin.com/raw/nJwskYhU