0

Similar questions look outdated compared to official guide. I do the following in Colab:

# Generating a new SSH key
!ssh-keygen -t ed25519 -C "your_email@example.com"
Your identification has been saved in /root/.ssh/id_ed25519.
Your public key has been saved in /root/.ssh/id_ed25519.pub.

Then I copy-paste the content of id_ed25519.pub ssh-ed25519 ..... your_email@example.com to new SSH Key window.

And test connection fails:

!ssh -T git@github.com
Host key verification failed.

What am I doing wrong?

dereks
  • 544
  • 1
  • 8
  • 25
  • Try `!ssh-keyscan github.com >> /root/.ssh/known_hosts` See https://stackoverflow.com/a/13364116/7976758 Found in https://stackoverflow.com/search?q=%5Bssh%5D+Host+key+verification+failed – phd May 23 '21 at 15:20
  • This returns an error `No such file or directory`. Can you share complete working example? – dereks May 23 '21 at 18:00

1 Answers1

1

The error message you're seeing, “Host key verification failed,” indicates that the remote server is unknown. Normally, in such a case, OpenSSH will prompt you with the fingerprint of the remote server and ask you to verify it. The official guide contains a link to the GitHub SSH key fingerprints.

However, in this case, you're running the command from another program without a TTY, so OpenSSH can't prompt you. You'll need to attempt to invoke the command from a terminal, then verify the fingerprint and then things should work.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • Thank you, do you know how to do that in `Colab`? – dereks May 23 '21 at 14:27
  • I don't. You won't be able to just shell out here; you'll need a real terminal. – bk2204 May 23 '21 at 14:28
  • You can add `-o StrickHostKeyChecking=no` to the `ssh` command line - only do that when you are sure you can trust your connection to github. – jingx May 23 '21 at 14:53
  • I didn't mention that because that's not a secure approach and it's impossible to know for certain that the connection isn't being intercepted when you're making it over the public Internet. – bk2204 May 23 '21 at 14:56
  • If you don't want to skip host key checking, do the `ssh` thing from a real terminal, confirm, and let it save the host key to your `~/.ssh/known_hosts`. Then write some code in Colab to append the new line to the `~/.ssh/known_hosts` at runtime before the `ssh` gets executed. – jingx May 23 '21 at 14:56
  • @bk2204 Agreed. I thought it would be better for OP to be aware of both the option and the risk. – jingx May 23 '21 at 14:58