I seem to have lost my permissions to a github account after pushing to it from another (local) repository. I am now receiving the following error:
git push
Permission denied (publickey).fatal:
The remote end hung up unexpectedly
I then took the following steps to regenerate a key:
ssh-keygen
Set up an ssh on my account for this laptop, using id_rsa.pub
However, this was unsuccessful. When I try the following code suggested, I receive the following error:
ssh-add -l
Could not open a connection to your authentication agent.
Any thoughts?
In terminal enter this command with your ssh file name pbcopy < ~/. ssh/id_rsa. pub This will copy the file to your clipboard Now open you github account Go to Settings > SSH and GPG keys > New SSH key Enter title and paste the key from clipboard and save it. Voila you're done.
If you want to use a password to access the SSH server, a solution for fixing the Permission denied error is to enable password login in the sshd_config file. In the file, find the PasswordAuthentication line and make sure it ends with yes . Find the ChallengeResponseAuthentication option and disable it by adding no .
This error comes up when using a wrong private key or no key at all when trying to connect via SSH. To resolve the problem, you should generate a new key pair and connect using that new set of keys.
I solved this problem following this step-by-step instructions:
Step 1: Check for SSH keys
$ cd ~/.ssh
# Checks to see if there is a directory named ".ssh" in your user directory
# If it says "No such file or directory" skip to step 3. Otherwise continue to step 2.
Step 2: Backup and remove existing SSH keys
$ ls
# Lists all the subdirectories in the current directory
# config id_rsa id_rsa.pub known_hosts
$ mkdir key_backup
# Makes a subdirectory called "key_backup" in the current directory
$ cp id_rsa* key_backup
# Copies the id_rsa keypair into key_backup
$ rm id_rsa*
# Deletes the id_rsa keypair
Step 3: Generate a new SSH key
$ ssh-keygen -t rsa -C "[email protected]"
# Creates a new ssh key using the provided email
# Generating public/private rsa key pair.
# Enter file in which to save the key (/home/you/.ssh/id_rsa):
# Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]
# Your identification has been saved in /home/you/.ssh/id_rsa.
# Your public key has been saved in /home/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]
Step 4: Add your SSH key to GitHub
$ sudo apt-get install xclip
# Downloads and installs xclip
$ xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
Then, go to GitHub, and do:
Step 5: Test everything out
$ ssh -T [email protected]
# Attempts to ssh to github
If ok, you'll see
Hi username! You've successfully authenticated, but GitHub does not
# provide shell access.
Otherwise (it happened with me), you will see
Agent admitted failure to sign using the key.
# debug1: No more authentication methods to try.
# Permission denied (publickey).
To solve this
$ ssh-add
# Enter passphrase for /home/you/.ssh/id_rsa: [tippy tap]
# Identity added: /home/you/.ssh/id_rsa (/home/you/.ssh/id_rsa)
For original info
https://help.github.com/articles/generating-ssh-keys
https://help.github.com/articles/error-agent-admitted-failure-to-sign
If you already have a public key in ~/.ssh (and have already added that key to your github account), you might only have to load your key into the SSH agent again.
To test if the SSH agent has the key, type ssh-add -l
If the result is:
The agent has no identities.
Then simply load your key into the SSH agent like this:
ssh-add ~/.ssh/github_rsa
(github_rsa is the name on my machine for the stored SSH key. This file can, among others, also be named: id_rsa)
After that you have to enter your passphrase for the key (this is likely your password to log into github). If you get a message like this:
Identity added: /Users/name/.ssh/github_rsa (/Users/cpotzinger/.ssh/github_rsa)
Doing an $ ssh-add
This worked for me to resolve the following as well for gitlab
jovimac-2:work joviano$ git clone [email protected]:bjetfweb.git
Cloning into 'bjetfweb'...
Access denied.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With