Using an Ubuntu server, I have the following user:
uid=1001(githubactions) gid=1001(githubactions) groups=1001(githubactions),27(sudo),33(www-data),998(docker)
logged in as this user, I create a ssh key pair with `ssh-keygen -t rsa -b 4096 -C "githubactions key" -f ~/.ssh/githubactions
When I run git clone git@github.com:user/repo.git I get: git@github.com: Permission denied (publickey)
Github has a very good article about that issue. When I run ssh-add -l -E sha256 I get Could not open a connection to your authentication agent..
Next, I add my private key to my ssh agent:
> eval "$(ssh-agent -s)"
Agent pid 1022567
> ssh-add ~/.ssh/githubactions
Enter passphrase for /home/githubactions/.ssh/githubactions:
Identity added: /home/githubactions/.ssh/githubactions (githubactions key)
I am now able to clone the repo. And now here is my issue:
When I log out and back in, I am again not able to clone the repo using ssh with the error git@github.com: Permission denied (publickey) again.
Do I maybe have this issue, because I renamed my files and don't use id_rsa?
The user must be able re-use the key after logout, as I want to use it to pull the repo remotely using GitHub actions.
eval "$(ssh-agent -s)"sets some variables in your current shell and exports them to the environment? Even if the agent survives your logging out (it may or may not survive), a new shell (after logging in again) has no means to know these variables. They are crucial if you want anything to communicate with the agent automatically. Can you usetmuxon the server to keep a shell (holding the variables) running? – Kamil Maciorowski Jul 11 '22 at 12:06KillUserProcesses=yes) kills all your processes when you log out. – Kamil Maciorowski Jul 11 '22 at 12:32~/.profilewith no effect. What changes is the message after I ranssh-add -l -E sha256:The agent has no identities..KillUserProcessesis commented in/etc/systemd/logind.conf. – Peter Pan Jul 11 '22 at 14:09