A small trick I've always used but I realized it might not be a well-known thing.
It is possible to test your authentication against a Git service over SSH with a very simple command:
ssh -T git@your-git-service.com
That's it. Pretty simple, right!? I do it all the time, to test if my SSH key is properly configured on a given Git service (GitHub, Gitea, sourcehut, etc.)
I'll put here some examples for popular Git services, so you can test it easily:
GitHub
$ ssh -T git@github.com
Hi joeljuca! You've successfully authenticated, but GitHub does not provide shell access.
GitLab
ssh -T git@gitlab.com
Welcome to GitLab, @joeljuca!
Bitbucket
ssh -T git@bitbucket.org
authenticated via ssh key.
You can use git to connect to Bitbucket. Shell access is disabled
Gitea
ssh -T git@gitea.com
Hi there, joeljuca! You've successfully authenticated with the key named [key name here], but Gitea does not provide shell access.
If this is unexpected, please log in with password and setup Gitea under another user.
sourcehut
ssh -T git@git.sr.ht
Hi joeljuca! You've successfully authenticated, but I do not provide an interactive shell. Bye!
That's it :) just a small Git/SSH trick for today. I hope it saves you some seconds when you're about to test your SSH-based Git authentication again!
Pro-tip: you can use the verbose mode to look way more hackish if you're testing the authentication in front of your girlfriend. 😂 Try running
ssh -Tv
instead ofssh -T
. 😉
Top comments (0)