I have a public-private key pair at ~/.ssh being used for SSH connection to GitHub.
In order to test if I've setup SSH with GitHub properly, I used ssh -T git@github.com, which works fine.
Also, If I execute the above command as superuser, it works fine.
su
ssh -T git@github.com
However, when I use sudo, the command isn't working. I suspect it's not able to access the key pair stored at ~/.ssh when run with sudo
The command below fails.
sudo ssh -T git@github.com
You can easily replicate the issue with any Ubuntu distribution and this GitHub help page.
Edit :
I understand that I can pass the private key to ssh as follows:
ssh -i <path-to-private-key> -T git@github.com
I'm just wondering why using sudo ssh -T git@github.com makes the private key inaccessible.