SOLVED !
A combination of small things was causing this
- My initial misconception re ssh keys being specific to users
- Two things were giving hard-to-understand results in my testing:
- I discovered my ssh passphrase was incorrect for one key, working on the other (check this with "$ssh-keygen -y")
- on the command line, ssh needs -i NOT -I to specify a key (duh)
- My config file as suggested.
Thank you to everyone for the help, much appreciated.
I am setting up a Git repository on my local network using SSH authentication. I followed the instructions found here on the official Git website: “Git on the Server - Setting Up the Server”
Trying to find some background to how it should work and why this setup is not working.
I am running Linux Mint 20 at the user workstation end, CentOS 7.1 on the Git server side.
I can SSH as user
from my-workstation
to gitserver
using public key authentication.
Copy SSH keys for user
from my-workstation
to the Git users .ssh
directory on gitserver
:
root@gitserver/srv # ls -l
drwxrwx---. 7 git git 4.0K 06/01/21 08:35 git
root@gitserver/srv # ls -ld git/.ssh/
drwx------. 2 git git 28 Jan 3 12:12 git/.ssh/
root@gitserver/srv # ls -l git/.ssh/
-rw-------. 1 git git 1.8K 03/01/21 21:45 authorized_keys
How does this work when SSH thinks I am the git
user with commands like:
git remote add origin git@gitserver:/srv/git/project.git
I don't understand how SSH keys for user
can allow ssh authentication for user git
.
The permissions for the repository on gitserver
are for user git
not user 'user`.
I am using a config file for the normal SSH access which does work, maybe that is the problem?
User alan
IdentityFile /home/alan/.ssh/my-workstation_alan-id_ed25519
IdentityFile /home/alan/.ssh/my-workstation_alan-id_rsa
IdentitiesOnly yes
Host gitserver
HostName GitserverIpAddress
This works for normal "non-git" access with:
$ ssh gitserver
Update:
In investigating the config file, a few more questions have arisen:
- There is no
git
user or group on the user workstation. In this case no.ssh/config
file and I presume the command "$ git push origin master" accesses the SSH system as the user issuing the command? - Do permissions in the traditional sense matter? The command
$ git push origin master
, I presume can access the repository on the Git server when the repository only allows access to user and groupgit
?
Tests:
- This first connection works, despite the initial error message
user@myworkstation~/files/git/Test $ ssh -I user-id_ed25519 user@gitserver
dlopen user-id_ed25519 failed: user-id_ed25519: cannot open shared object file: No such file or directory
Enter passphrase for key '/home/user/.ssh/user-id_ed25519':
Last login: Tue Jan 12 09:15:17 2021 from aa.bb.cc.dd
user@gitserver: $ exit
logout
Connection to aa.bb.cc.dd closed.
- This second connection does not
user@myworkstation~/files/git/Test $ ssh -I user-id_ed25519 git@gitserver
dlopen user-id_ed25519 failed: user-id_ed25519: cannot open shared object file: No such file or directory
git@aa.bb.cc.dd: Permission denied (publickey).
user@myworkstation~/files/git/Test $