I cannot connect to git using ssh

Not really - It has never happened to me (Denmark) - so I am speculating that it could be network related. Perhaps not your local network - but the wider internet - depending on your location …

So you are able to connect to github using ssh.

That does not change your network connection capabilities.

Some help to do basic network troubleshooting can be found in below mini guide - you may want to disable IPv6 as this can sometimes be the joker - I remember several topics where IPv6 played a role