Assign the user www-data an SSH key and add it to the remote repo
Last updated on
29 October 2019
In the GIT Info Report, for public repos, you get warned if your local repo is behind, compared with the remote. To have the same information also for private repos, you should create an SSH key for the user www-data and add that key to your user profile on the remote repo.
Steps
- Check first what user is being used to run the CLI commands integrated into the module. In most cases, the user is www-data. We presume that in the rest of the instructions below. Substitute if necessary.
- In the terminal:
- Create a new hidden directory:
sudo mkdir /var/www/.ssh
- Change folder permission:
sudo chown -R www-data /var/www/.ssh
- Create the ssh key as user www-data:
sudo -u www-data ssh-keygen -t rsa
- Create a new hidden directory:
- Open the generated key file (/var/www/.ssh/id_rsa.pub) with a text editor and copy-paste the content to your user profile SSH Keys on the remote repo. On GitLab, when logged in, this is found at https://gitlab.com/profile/keys/.
- Then in the terminal from a Git repo, use
sudo -u www-data git ls-remote
to provoke the first connection to the remote repo as user www-data manually. It will say The authenticity of host X can't be established. Confirm you would like to add it to the list of known hosts. All points above are a one-time operation, per machine, per repository service provider. Once set correctly, it does not need to be repeated, not even for another project. - Refresh the Status Report and check if after the remote repo address you now see either No pull needed or Your branch is behind. If so, it works as expected.
More info
Help improve this page
Page status: No known problems
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion