I set up an SSH server that contains a git repository. I have a user that can remotely connect to that ssh server using SSH keys (generated with ssh-keygen
and then communicated to the server with ssh-copy-id
), so that when I use the command ssh git@serverIP
it connects without requiring the user to type the server password.
But when that same user tries to push to the repository with git push
it asks for the server password, as if the user never shared the SSH key. I suppose I have to configure the git repository to use the SSH keys, as this question addresses in the case of gitlab repositories. Note that i'm not using GitHub either.
Using git remote -v
gives:
origin git@serverIP:repository.git (fetch)
origin git@serverIP:repository.git (push)
My goal is to be able to execute a script that can push to the repository without needing user interaction, i.e. without asking the password. Any idea? Help would be much appreciated...
Edit:
Setting up again the repository actually fixed the problem. As a side note, when executing the script it still asked for the password: the problem was that I was executing the script with sudo
, meaning that it was no longer the user to push to the repository, but root (that didn't have SSH keys). Hope this note can help someone else.