Home > OS >  ssh -T [email protected] user upon login
ssh -T [email protected] user upon login

Time:09-25

in my macos, ssh -T [email protected] showing me logged in as xyz.

Where is the id xyz coming from? how do I change it to the git account I want in upon login? right now I am changing it using the ssh-add in my shell .profile script, but just thought it must be coming from somewhere in the first place?

CodePudding user response:

Let's break down what's happening here:

ssh -T [email protected]

This attempts to open an SSH connection to a server at "bitbucket.org" with username "git". The "-T" just stops it trying to actually open an interactive connection - the effect is to log in and immediately log out again.

using the ssh-add in my shell .profile script

In order to succeed at all, the SSH client has to authenticate with the server. It does this using a public-private key pair, which is automatically negotiated between client and server. Your "ssh-add" command is part of an "authentication agent", which holds a list of keys to offer to servers; if the server at bitbucket.org says it recognises one of those keys, that key is automatically used to authenticate the connection.

Remember at this point, you're just authenticating as the user "git"; bitbucket.org has said that it recognises one of your keys, and an SSH connection is established.

showing me logged in as xyz

What happens next is that the server at bitbucket.org looks up the key you used in its own database, and notes that it is associated with a user on the BitBucket service. It prints a helpful message telling you which user that is, and closes the SSH connection.

This isn't a "user" as far as SSH is concerned, and it's not something git knows about either. It's entirely something that the server at bitbucket.org controls.

how do I change it to the git account I want in upon login?

By choosing the key you authenticate with, and associating that key with a BitBucket user in their settings panel. You have no other control than that, because the user only exists in their database.

  • Related