This is my first time accessing github and I'm not experienced using console. I'm on a Macbook (using Bash). When I try to access github, I get this:
git clone git@github.com:dhulihan/league-of-legends-data-scraper.git
Cloning into 'league-of-legends-data-scraper'...
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 following the instructions on Github page about Permission denied When I use ssh -vT git@github.com, I get the following:
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to github.com [192.30.252.129] port 22.
debug1: Connection established.
debug1: identity file /Users/XXXX/.ssh/id_rsa type -1
debug1: identity file /Users/XXXX/.ssh/id_rsa-cert type -1
debug1: identity file /Users/XXXX/.ssh/id_dsa type -1
debug1: identity file /Users/XXXX/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version libssh-0.6.0
debug1: no match: libssh-0.6.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Users/XXXX/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/XXXX/.ssh/id_rsa
debug1: Trying private key: /Users/XXXX/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).
Next, eval "$(ssh-agent -s)" returns "Agent pid 2314" However, ssh-add -l returns "The agent has no identities."
And that's where I'm stuck. I've tried googling this problem and searching here on SO. I've tried accessing files in the ssh directory, but there are none. Just a folder called Knownusers.
Can someone help me with this issue?
try this:
worked for me
first of all you need to go in your ssh directory
for this type following command in your terminal in mac or whatever you use in window
now it is in the ssh
here you can find all you ssh key/files related to your all projects. now, type the following command to show you if any ssh key available
this will show you all available ssh, in my case there were two
now, you will need to start an agent to add a ssh in it. For this type following command
now last but not least you will add a ssh in this agent type following command
replace
One additional element that I realized is that typically .ssh folder is created in your root folder in Mac OS X /Users/. If you try to use ssh -vT git@github.com from another folder it will give you an error even if you had added the correct key.
You need to add the key again (ssh-add 'correct path to id_rsa') from the current folder to authenticate successfully (assuming that you have already uploaded the key to your profile in Git)
Steps for BitBucket:
if you dont want to generate new key, SKIP ssh-keygen
Copy the public key to clipboard:
Login to Bit Bucket: Go to View Profile -> Settings -> SSH Keys (In Security tab) Click Add Key, Paste the key in the box, add a descriptive title
Go back to Git Bash :
You should get :
Now:
git pull
should workFull details in this answer.
In summary, when
ssh-add -l
returnsThe agent has no identities
it means that keys used byssh
(stored in files such as ~/.ssh/id_rsa, ~/.ssh/id_dsa, etc) are either missing, they are not known to the authentication agent (ssh-agent
), or their permissions are set incorrectly (e.g., world writable).If your keys are missing (i.e., you have not generated any keys), use 'ssh-keygen' (e.g.,
ssh-keygen -t rsa
) to generate them, then usessh-add
to add them.If keys exist but are not known to
ssh-agent
(e.g., they may be in a non-standard folder) use 'ssh-add' (e.g.,ssh-add /path/to/my-ssh-folder/id_rsa
) to add them.See this answer if you are having trouble with
ssh-add
orssh-agent
.I have been stucked a while on the same problem, which I eventually resolved.
My problem: I could not execute any push. I could check & see my remote (using
git remote -v
), but when I executedgit push origin master
, it returned :Permission denied (publickey). fatal: Could not read from remote repository.
and so.How I solved it :
ssh-keygen -t rsa
. Entering a name for the key file (when asked) was useless.ssh-add /Users/federico/.ssh/id_rsa
, which successfully returnedIdentity added: /Users/myname/.ssh/id_rsa (/Users/myname/.ssh/id_rsa)
ssh-add -l
command worked / seemed useful (after having ran the previous steps), it successfully returned my key. The last step shows you where to check your public key on your GitHub page. And this command will help you check all your keys :ls -al ~/.ssh
.Then the push command eventually worked !
I hope this will help ! Best luck to all.