I created a .gitlab-ci.yml file.
the project is already in the remote server.
I created gitlab-runner in my remote server and I chose the shell option.
my file .gitlab-ci.yml just makes the update for the project i.e. (we will do "git pull origin master"
and here is my .gitlab-ci.yml script
stages:
- build
before_script:
- cd/home/devops/projects/my-project
building:
stage: build
script:
- git status
- sudo git pull origin master
when I run the pipeline i get this error.
$git pull origin master.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists. "
please how could we solve this problem?
I'm really stuck with this problem
thank you so much
It seems like an issue with your ssh keys between the gitlab-runner host and gitlab. This topic might answer your question:
Git-error-host-key-verification-failed-when-connecting-to-remote-repository
Basically, log in your gitlab-runner host and check ${HOME}/.ssh/known_hosts. You should see the current public key from your gitlab host. If not, you will need to remove it and update it.
Related
When i try to execute the pipeline in gitlab ci, i get an error like fatal: repository 'http://practice-host.dfsystems.ru/gitlab-instance-8435ed1c/objective.git/' not found
enter image description here
My gitlab-runner deployed in kubernetes cluster
enter image description here
Deployed with helm with this yaml file:
enter image description here
I did ssh-keygen in gitlab-runner and added in gitlab ssh-keys, but still not working
This pipeline what i use now
enter image description here
If you have any idea, i will appreciate it <3
Here are some steps you can try to resolve the issue:
Verify the repository URL: Make sure that the URL you're using is correct and that you have access to the repository.
Check the GitLab instance: If you're using a self-hosted GitLab instance, check that it is accessible and reachable from the GitLab CI runner.
Check authentication: If the repository is private, make sure that the GitLab CI runner has the necessary access token or SSH key to clone the repository.
Check network connectivity: Ensure that the GitLab CI runner has network connectivity to the GitLab instance and the repository.
I was new to Gitlab was trying to push my project from local machine to Gitlab.
Have done the SSH key and followed the instructions at Gitlab. Done the Git global setup. Was trying to add an existing folder , so i followed the instructions listed
cd existing_folder
git init
git remote add origin https://gitlab.com/sss/testnode.git
git add .
git commit -m "Initial commit"
git push -u origin master
but failed at the last step at the git push. The error message was
Tried adding the remote origin, but it was told it already exists. So not sure where it went wrong. Please help, much appreciated :)
Have done the SSH key
The problem is that you have defined your origin as HTTPS, not SSH.
Try:
git remote set-url origin git#gitlab.com:sss/testnode.git
That will override origin URL.
Independently, make sure your SSH key does work and allows GitLab to authenticate you as your GitLab account with:
ssh -T git#gitlab.com
Check out your credentials, if they are invalid, it wont give u to upload changes.
For Windows check this: https://www.digitalcitizen.life/credential-manager-where-windows-stores-passwords-other-login-details
For Linux check this: https://askubuntu.com/questions/30907/password-management-applications (if you do not know how to change credentials via terminal)
I am working on a project which I want to publish in GitHub pages. To automate the deploying process I'm using Travis CI. For this I have created a deploy.sh file, which has the following code.
# build
npm run docs:build
# navigate into the build output directory
cd docs/.vuepress/dist
# if you are deploying to a custom domain
# echo 'www.example.com' > CNAME
git add -A
git commit -m 'deploy'
# if you are deploying to https://<USERNAME>.github.io
# git push -f git#github.com:<USERNAME>/<USERNAME>.github.io.git master
# if you are deploying to https://<USERNAME>.github.io/<REPO>
git push -f git#github.com:<username>/<repo>.git master:gh-pages
cd -
I have added this in my .travis.yml file, which is below
language: nodejs
node_js:
- "lts/*"
before_script:
- npm install
script:
- bash ./scripts/deploy.sh
Now when I push my code to the master, In travis-ci.org it shows that the build is failed, with the following outputs,
Warning: Permanently added the RSA host key for IP address '192.30.253.113' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
The command "bash ./scripts/deploy.sh" exited with 128.
I have followed other SO answers of the same type of errors like this link and also followed the way to generate and adding ssh key to my GitHub account but no success. I will be grateful if you could help me out. Thank you.
If you want to push via ssh then travis needs to have access to the private part of the ssh key you generated. What you want to do is use the travis cli gem to encrypt the private key, add it to your repo and during the deploy stage decrypt it again and use it.
Here's a step-by-step
I have created a new user on github under our organization which will be used for auto deployment. I followed the article on https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#platform-linux.
Somehow, when I tried to clone the repository to the server, it worked once. The code was running properly, and I exit the server. Today, we released an update to the code, and I wanted to deploy the code manually to the server, so I ssh'd into the server and tried to pull the repository with git pull. It gave me Permission denied error. After some debugging I realized that the ssh-agent wasn't running. So I executed the following commands:
eval "$(ssh-agent -s)"
ssh-add .ssh/id_rsa_staging
Now, when I try ssh -T git#github.com, I see the welcome message which is:
Hi *****! You've successfully authenticated, but GitHub does not provide shell access.
But when I try to pull from the repository, I am continuously getting this error message:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I checked the repository and the user has read access to it. I double checked if the keys match on github and server, yes they do. I tried generating new keys. I tried using ssh/config file. Nothing helped...
I appreciate any help & suggestions!
Update:
So I figured out that git clone command is working properly, but even when I try git pull right after git clone, it is giving the error.
If you are using sudo to git pull/push to the remote you need to ensure you used sudo to generate your SSH keys. Otherwise you will not be using the same keys that you originally generated.
github doc for reference
I had the exact same issue.
For me what worked was
Go to repo on github which you have cloned and wanna pull with
Under the code-download option copy SSH link
Enter following command in your terminal -->
git remote set-url origin paste_SSH_link
I would like to pull the changes as user 'ubuntu' during startup.
The upstart file is:
description "Custom startup script"
start on filesystem
script
cd /var/www/gitstuff
git checkout master
git pull
end script
When I rebooted I got this log message:
Already on 'master'
Host key verification failed.^M
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have a feeling when the upstart script runs it is being executed as root user.
Used this for the pull statement:
git pull ubuntu#example.com:/etc/drupal/7/gitstuff
Also had to add keys to the root user
try:
script
cd /var/www/gitstuff
su - ubuntu git checkout master
su - ubuntu git pull
end script