ssh-agent don't work,i cannot connect to my git server - ssh-agent

[suiyimen#localhost ~]$ ssh-add ~/.ssh/id_rsa_git
but return no such device or address
[suiyimen#localhost ~]$ ls -la ~/.ssh
it shows: id_rsa_git -> /tmp/ssh-DvbhW17778/agent.17778
I don't what do this mean.how can i solve the problem.I cannot git pull repo from my git server anymore.

Related

steps to clone a private repository using Google Colab

I want to clone a private repository in Google Colab,
I opened a notebook on colab and did the following:
%cd "content/drive/My Drive/project"
!rm -rf /root/.ssh*
!mkdir /root/.ssh
!ssh-keygen -t rsa -b 4096 -C "githubname#github.com"
then I opened the public key by
!cat /root/.ssh/id_rsa.put
I copied the public key that is displayed after I ran the command and made a new key in my GitHub using this key.
Then I tried the following:
!ssh-keyscan GitHub.com >> /root/.ssh/known_hosts
!chmod 644 /root/.ssh/known_hosts
!chmod 600 /root/ssh/id_rsa
!ssh -T github.com
then I get the following (permission denied)
# github.com:22 SSH-2.0-babeld-d45c1532
# github.com:22 SSH-2.0-babeld-d45c1532
# github.com:22 SSH-2.0-babeld-d45c1532
Warning: Permanently added the RSA host key for IP address '140.82.113.3' to the list of known hosts.
root#github.com: Permission denied (publickey).
What do I do next?
ssh -T github.com
root#github.com: Permission denied (publickey)
That would be expected:
the right test would be:
ssh -T git#github.com
the right SSH URL to use with GitHub would be:
git#github.com:<me>/<myRepo>
You always use "git", not "root" (or your current local user) as the remote user to connect to GitHub.
Your local account remains "root" (it contains the public and private SSH key)
But connecting to GitHub means using the remote account git.

How do I commit changes to a repository while I am 1 behind and 2 ahead?

So I am 1 behind and 2 ahead on this GitHub repository.
When I got to pull to solve the 1 behind problem it gives me this output:
git --no-optional-locks -c color.branch=false -c color.diff=false -c color.status=false -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree fetch origin
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'm not really sure what this means and would like to solve this issue as soon as possible and upload some files onto the repository.
I'm a beginner when it comes to GitHub and SourceTree.
It means the way SourceTree uses SSH fails to authenticate you on GitHub.
Check first if, in command line, ssh -T git#github.com works: see "Testing your SSH connection".
Then check sourceTree settings: as shown here, I would recommend using the OpenSSH client, not the putty one (assuming you have used ssh-keygen -t rsa -P "" -m PEM to generate your ssh private/public key pair, and not putty, or that you are not on Windows)

Github ssh key added, checked, still doesn't work

I created ssh key as per this tutorial.
Assigned it to the ssh-agent.
Added it to the github account as per this tutorial.
ssh-add -l -E md5
Shows correct footprint
ssh -T git#github.com
Says:
Hi <My username>! You've successfully authenticated, but GitHub does not provide shell access.
But still:
git push
Asks for:
Username for 'https://github.com':
Any idea? Thanks in advance.
Check out this: switching-remote-urls-from-https-to-ssh
High are the changes that you clone your repo over HTTPS and now want to push using SSH.
As suggested on the GitHub site check your remote origin by doing this:
$ git remote -v
origin https://github.com/USERNAME/REPOSITORY.git (fetch)
origin https://github.com/USERNAME/REPOSITORY.git (push)
In case you have https... change it to ssh by doing something like this:
git remote set-url origin git#github.com:USERNAME/REPOSITORY.git

SSH Agent Forwarding not working

I'm having an hard time trying to configure Capistrano 3.1 to deploy an app hosted on Github.
I'm following Capistrano Documentation and I have successfully completed the first step (SSH keys from workstation to servers) and on the second one (From our servers to the repository host) I'm able to successfully run ssh -A deploy#one-of-my-servers.com 'git ls-remote git#github.com:my_user/my_repo.git':
18f38afz261df35d462f7f4e2ca847d22f148a06 HEAD
18f38afz261df35d462f7f4e2ca847d22f148a06 refs/heads/master
however, ssh deploy#one-of-my-servers.com 'git ls-remote git#github.com:my_user/my_repo.git' fails:
Permission denied (publickey).
Capistrano docs suggests
If you get the error "host key verification failed." log in into your server and run as the deploy user the command ssh git#github.com to add github.com to the list of known hosts.
SO, I tried so but I get
ssh git#github.com
Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.
Permission denied (publickey).
And I'm basically not able to successfully access the Github repo.
SSH documentation states:
-A Enables forwarding of the authentication agent connection. This
can also be specified on a per-host basis in a configuration
file.
How can I specified on a per-host basis in a configuration file?
My local machine runs Mac OSX Mavericks.
The VPS runs Ubuntu 12.04
Thanks.
Do you have your ssh key added to the list of agent identites ?
You can check with ssh-add -L , you should see the key your are using to connect to github :
$ ssh-add -L
ssh-rsa AAAAB3N.....0VmSiRvTzBrbU0ww== /Users/youruser/.ssh/id_rsa
If you don't see the ssh key you use for github or a message like
The agent has no identities.
Then you should add your key with :
ssh-add ~/.ssh/id_rsa
(replace with the path to the key you use for github)
See the ssh-add doc for more info
Add following lines to .ssh/config file on your local computer
Host Server_Address
ForwardAgent yes
Check your local key whether listed in ssh-add list or not with
ssh-add -L
If not add key to SSH Agent
ssh-add -K
Connect to Remote Server
ssh -v username#Server_Address
Check SSH Agent forwarding is enabled by running following command. It should list a socket file
echo "$SSH_AUTH_SOCK"
Run connection test against GitHub
ssh -T git#github.com
Run ls remote test against targeted git repository
git ls-remote --heads git#github.com:account/repo.git
Finally logout and run following from your local machine
cap production git:check
Add the following to ~/.ssh/config
Host one-of-my-servers.com
ForwardAgent yes
Yet another cause: If the target host's fingerprint doesn't match with your ~/.ssh/known_hosts, SSH automatically disables Agent Forwarding.
The solution is:
$ ssh -A -o UserKnownHostsFile=/dev/null my-target-host

cant add a file into github

I want to add a file into github as follow:
git init
touch test.txt
git add test.tst
git cmmit -m'testtest'
git push origin master
then it will raise this exception:
error: The requested URL returned error: 403 while accessing https://github.com/yacheng1127/YWProject.git/info/refs
fatal: HTTP request failed
then I verify the public key is attached to my github account:
$ ssh -T git#github.com
Hi yacheng1127! You've successfully authenticated, but GitHub does not provide shell access.
$ ssh-add -l
2048 1a:a1:33:26:21:68:7e:9c:26:19:fb:74:a4:d1:6b:bd yacheng1127#gmail.com (RSA)
then I check my remote url:
$ git remote -vorigin
origin https://github.com/yacheng1127/YWProject.git (fetch)
origin https://github.com/yacheng1127/YWProject.git (push)
I don't know where is the problem. could somebody help me? thank you
Use ssh key is used when you use the "git://" url for your remote, you can change this (https://help.github.com/articles/changing-a-remote-s-url).
But "https://" should work too (read/write), but it can't use your ssh key nor ssh agent, you should give git your github login and password :
https://help.github.com/articles/set-up-git#password-caching