Let me share my experience too,
I was trying to clone some project from the Gerrit repo where I got my public keys in account settings.
On the first attempt to make git clone
I got the following error:
Unable to negotiate with XX.XX.XX.XX port XXX: no matching key exchange
method found. Their offer: diffie-hellman-group1-sha1
I figured out that I need to pass the SSH option -oKexAlgorithms=+diffie-hellman-group1-sha1
somehow to git clone
.
Hopefully GIT_SSH_COMMAND
environment variable did the job:
export GIT_SSH_COMMAND="ssh -oKexAlgorithms=+diffie-hellman-group1-sha1"
But git clone
still didn't start to work.. Now it throws the (on topic):
Permission denied (publickey).
I got already SSH keys and didn't want to regenerate them. I checked plain SSH connection to the host and it was ok:
**** Welcome to Gerrit Code Review ****
Hi XXXXX, you have successfully connected over SSH.
Unfortunately, interactive shells are disabled.
To clone a hosted Git repository, use:
git clone ssh://xxxxx@xx.xx.xx:xxx/REPOSITORY_NAME.git
I was confused a bit. I started again and turned on the debug for SSH via -vvv
option. And I saw the following:
debug1: read_passphrase: can't open /dev/tty: No such device or address
Possibly, it was an overhead for the GIT_SSH_COMMAND
env variable - my key was secured with passphrase (and I entered it when I was checking the login to the git repo host).
So, I decided to get rid of the phasphrase then. A simple command helped me:
ssh-keygen -p
Then I entered my passphrase for the "old passphrase" and just hit ENTER twice on the "new passphare" to leave it empty i.e. with no passphrase at all and to confirm my choice.
After that I got the freshly cloned repo on my local disk.