- Generate SSH key using
ssh-keygen -t rsa -b 4096 -C "your email". - Copy the output of
cat ~/.ssh/id_rsa.pubto your clipboard - Paste the above-copied output to the form at https://github.com/settings/ssh/new
- Then go ahead to retry the operation that generated the initial fatal error.
Update: If you are still facing “ssh: connect to host github.com port 22: Connection timed out”, then follow the below steps.
Check the connection, mostly it will time out
$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out
Check the same by providing optional param port
$ ssh -T -p 443 git@ssh.github.com
Hi <user_name>! You've successfully authenticated, but GitHub does not provide shell access.
Update the SSH settings
$ vim ~/.ssh/config
# Add github in the know hosts
Host github.com
Hostname ssh.github.com
Port 443
Check the connection, mostly it will connect this time
$ ssh -T git@github.com
Hi <user_name>! You've successfully authenticated, but GitHub does not
provide shell access.