Trying to read id_rsa - github

I am trying to read cat id_rsa, but is it throwing
cat: id_rsa: Permission denied
Also is not letting me push changes to the repository by saying
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
What am i missing

Need root use permission to read this file so use
sudo cat id_rsa

Did you try with sudo to read the file?
sudo cat id_rsa.pub
To my knowledge anyways the ssh key needed for GitHub is the publickey.
To further debug your problem, you might want to make sure that the ssh key is actually added to your github account and has the right permissions.
You can debug if your ssh key is being used with your account by following the steps here
further steps of debugging the issue that might be helpful can be found here (e.g. verifying that your user can make connections after verifying the ssh key)

Related

GitHub ssh keys - ssh test works but using git clone returns permission denied

I've been working on this for a few hours now and I've read everywhere but am officially stumped.
I'm trying to set up ssh keys for a dev-environment to interact with github. I've followed the guide on github and have made the keys and when I test them using the git#github.com it works but when I use git clone git#github.com:username/repo I get
Cloning into 'reponame'...
git#github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
I've tried adding it to ssh-add and that works, ssh-agent is running and has access. I've looked at the environment variable and set it to ssh among a few other things. I don't know what else to try. Let me know what logs I can post to help.
My thoughts are maybe the git command isn't using the identities or the right ssh client but other than the environment variables I'm not sure what else to change.
Thanks for the help in advance.

Github SSH issue 'Permission Denied'

I am stuck on this annoying (and common) issue running Manjaro (latest). SSH works just fine for me on my local network. I can connect to my file server and pi-hole just fine.
GitHub however is proving more difficult.
gh repo clone User/Reponame gives the following:
WARNING: cgroup v2 is not fully supported yet, proceeding with partial confinement
Cloning into 'Reponame'...
warning: templates not found /usr/share/git-core/templates
The authenticity of host 'github.com (140.82.121.3)' can't be established.
RSA key fingerprint is SHA256:SomeLongNumberBlahBlah.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/USER/.ssh/known_hosts).
Load key "/home/USER/.ssh/id_rsa": Permission denied
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
exit status 128
Now I tried deleting my known_hosts, checking the file permission, creating new keys for my server/pi-hole and all works fine. I don't see why GH is struggling with permission. I've tried a few solutions but nothing seems to work for me. I've set my global user and email for github, I just can't get passed this step.
ssh -T git#github.com Asked for a passphrase and accepted it when I entered. Yay! I have both keys set and added to github.com via my browser etc. I must be missing something.
Still no change in the clone command. I am honestly stuck having read multiple threads on the subject. SSH always gets me :(

Permission denied to new ssh user when pushing

I'm using terminal, I want to delete ssh keys from and old user (old_username) and set a new one (new_username). I have done as is in this tutorial.
When I run: ssh -T git#github.com I get the correct message:
`Hi new_username! You've successfully authenticated'.
But when I try to push a repository I get denied:
remote: Permission to new_username/test2.git denied to old_username.
fatal: unable to access 'https://github.com/new_username/test2/': The requested URL returned error: 403
I've tried deleting .ssh folder and setting again ssh, but the problem persists.
Using an https url means your ssh connection is not used. At all.
Try switching to ssh:
git clone git#github.com:new_username/test2
That will actually use your ssh credentials, meaning your public and private keys stored in ~/.shh/id_rsa(.pub).
If on Linux or OSX, check a file called ~/.netrc, which contains username/password information that most apps will use when connecting to remote servers. Yes, it even affects git via the https protocol. If you're using a frontend to connect to github, you probably need to clear its preferences so it stops trying to use the old username.

Permission denied (publickey). fatal: The remote end hung up unexpectedly for git pull

I am using Ubuntu 12.04
Kannan#Ubuntu:~/a/git pull
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
How to resolve this issue. Please do let me know
I think this is due to ssh problem
Make sure whether your key is in the .ssh folder, if yes, then do the following one
Open ~/.bashrc & add
eval `ssh-agent -s`
ssh-add ~/.ssh/your_respective_key
and do bash on terminal and do git pull.I hope it will work
You need to make sure the public key you've registered with Github is the one for the user doing the Git pull.
The Github guide for setting up keys is well laid out, and they have a linux version:
https://help.github.com/articles/generating-ssh-keys#platform-linux
Make sure it's definitely the correct user's public key, and you have not included any whitespace at the end of the key - the key finishes at the end of your email address.
ssh-rsa 8f97gs89dfng746c74nyc7n478cb6ts746tb8746tbv9846cyb78
sjfghsfg43534639fb09bg0g098243hfjc0478tjwygjw85jywcyhwj9y598
dfhghuh3546ntnfgskjvgiu34b6t3== you#example.com
That is the end of your key ----^

Jenkins returned status code 128 with github

With GitHub command I have:
ssh -T git#github.com
Hi (MyName)! You've successfully authenticated, but GitHub does not provide shell access.
My connection with GitHub is ok (no problem), but with Jenkins I have this error:
ERROR: Error cloning remote repo 'origin' : Could not clone git#github.com:Name-MysRepo/MyRepo.git
hudson.plugins.git.GitException: Could not clone git#github.com:Name-MysRepo/MyRepo.git
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clone(CliGitAPIImpl.java:219)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1001)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:942)
at hudson.FilePath.act(FilePath.java:904)
at hudson.FilePath.act(FilePath.java:877)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:942)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1369)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
at hudson.model.Run.execute(Run.java:1575)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:241)
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin git#github.com:Name-MysRepo/MyRepo.git /root/.jenkins/jobs/TestKRGDAOV01/workspace" returned status code 128:
stdout: Cloning into '/root/.jenkins/jobs/TestKRGDAOV01/workspace'...
stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Is this problem with public key?
I use Jenkins under Tomcat 7 / Ubuntu 12.
This error:
stderr: Permission denied (publickey). fatal: The remote end hung up unexpectedly
indicates that Jenkins is trying to connect to github with the wrong ssh key.
You should:
Determine the user that jenkins runs as, eg. 'build' or 'jenkins'
Login on the jenkins host that is trying to do the clone - that is, do not login to the master if a node is actually doing the build.
Try you ssh to github - if it fails, then you need to add the proper key to <jenkins user home>/.ssh
To check are the following:
if the right public key (id_rsa.pub) is uploaded to the git-server.
if the right private key (id_rsa) is copied to /var/lib/jenkins/.ssh/
if the known_hosts file is created inside ~/.ssh folder. Try ssh -vvv git#github.com to see debug logs. If thing goes well, github.com will be added to known_hosts.
if the permission of id_rsa is set to 700 (chmod 700 id_rsa)
After all checks, try ssh -vvv git#github.com.
Also make sure you using the ssh github url and not the https
In my case I had to add the public key to my repo (at Bitbucket) AND use git clone once via ssh to answer yes to the "known host" question the first time.
i had sometime ago the same issue.
make sure that your ssh key doesn't have password and use not common user account (e.g. better to user account called jenkins or so).
check following article http://fourkitchens.com/blog/2011/09/20/trigger-jenkins-builds-pushing-github
When I got a similar status code 128 error from Jenkins:
status code 128:
stdout:
stderr: fatal: Couldn't find remote ref refs/heads/jenkins
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2172)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1864)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:78)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:545)
at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:358)
at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:113)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:67)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:299)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE
It was because I hadn't pushed my new branch "jenkins" that had my Jenkinsfile. So the solution was to just push my changes
I deleted my project (root folder) and created it again. It was the fastest and simplest way in my case.
Do not forget to save all you changes, before you delete you project!
I first had another credential, then when i deleted that, and created a new one, i had the same error. I had to go to every project, and select the new Credential.
I changed the permission of my .ssh/id_rsa (private key) to 604.
chmod 700 id_rsa