'Managing ssh keys

Suppose that I have a remote server and GitLab private repository.

I do not want to add key from my server to ssh keys in GitLab account, so I make ssh key forwarding.

However, when I try to run my initial installation scripts with sudo, I cannot pull the repository because with sudo my ssh keys are not accessible on the server.

How can I handle it?



Solution 1:[1]

Check first, as in here, if you can allow the other user (sudo -u otheruser) to access $SSH_AUTH_SOCK file, and it's directory.

That way, you would still benefit from the original SSH tunnel: simply giving more permission to $(dirname $SSH_AUTH_SOCK) can be enough.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VonC