14

I'm trying to connect to AWS CodeCommit with SSH. I've followed every step in this guide:

https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-windows.html#setting-up-ssh-windows-install-git

but when I get to where I need to run the following command

ssh MY-SSH-KEY@git-codecommit.us-east-2.amazonaws.com

I get this error

Unable to negotiate with 52.95.17.51 port 22: no matching host key type found. Their offer: ssh-rsa

torek
  • 448,244
  • 59
  • 642
  • 775
Austin Grant
  • 391
  • 3
  • 7

2 Answers2

25

Nvm i found a solution i had to add this to my .ssh/config file

HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa

if you getting this error after you added those two lines

Bad configuration option: \240\240pubkeyacceptedkeytypes

is because the spaces in the config file arent spaces their 240 characters

this helped me

Bad configuration option: \240\240user when setting up Amazon CodeCommit

what i did was copy the spaces that were on my other lines and used them in the new lines i added

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
Austin Grant
  • 391
  • 3
  • 7
  • Small clarification: the content that Austin Grant shows is in fact in two lines, Line 1: `HostKeyAlgorithms +ssh-rsa`, and line 2: `PubkeyAcceptedKeyTypes +ssh-rsa` – coderazzi Dec 07 '21 at 23:44
  • @coderazzi thank you. I now corrected the answer to reflect that. – Pablo Fernandez Dec 27 '21 at 10:49
  • Further clarification - those two lines should go within the specific config you set up to connect to AWS code commit. It is possible to have multiple `Host` entries in the config file and you need to ensure you're putting it under the CodeCommit `Host`. It would be useful to demonstrate this in the answer, with a fuller sample of the surrounding context including an additional host (different to AWS CodeCommit). – Colm Bhandal May 18 '22 at 16:08
  • On my case the setup was exactly as (aws 2022 june) describes https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-unixes.html . Adding these two lines helped me. Thanks – JRichardsz Jun 17 '22 at 17:19
0

For me, the problem was that windows was referring to the wrong root hard drive disk. (because pc managed by system administrators)

The solution was to create a new environment variable called HOME. With the directory of your .ssh folder.

  • press windows key
  • write edit environment

enter image description here

  • Click on the first new button

enter image description here

  • variable name = HOME
  • variable value = directory of your .ssh folder

enter image description here

  • press ok

  • press the other ok to save the changes.

  • Apply @Austin Grant answer afterwards if it doesn't work.

Mo D Genesis
  • 5,187
  • 1
  • 21
  • 32