DEV Community

Joel Jucá
Joel Jucá

Posted on

Test your SSH-based Git auth

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
Enter fullscreen mode Exit fullscreen mode

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.
Enter fullscreen mode Exit fullscreen mode

GitLab

ssh -T git@gitlab.com
Welcome to GitLab, @joeljuca!
Enter fullscreen mode Exit fullscreen mode

Bitbucket

ssh -T git@bitbucket.org
authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled
Enter fullscreen mode Exit fullscreen mode

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.
Enter fullscreen mode Exit fullscreen mode

sourcehut

ssh -T git@git.sr.ht
Hi joeljuca! You've successfully authenticated, but I do not provide an interactive shell. Bye!
Enter fullscreen mode Exit fullscreen mode

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 of ssh -T. 😉

Top comments (0)