Setting default SSH user for tsh

Is it possible to set the default SSH user when using teleport (So I don’t have to keep doing tsh ssh myawesomeusername@theserver)?

With SSH it’s possible to set this in the .ssh/config file with something like:

Host *
	User myawesomeusername

Specifying the user with tsh login --user=myteleportuser only changes the user that’s logged into teleport, not the user that is actually connecting to servers.

According to the documentation, tsh assumes that you are $USER if you don’t specify a username. Theoretically if you set/export this environment variable on the machine where you’re running tsh, you could avoid typing the username.

Let us know whether it works.

Didn’t work. :thinking:

mybox:~ sskousen$ tsh ssh teleport-dev-proxyA
sskousen@teleport-dev-proxyA:~$ exit
logout
the connection was closed on the remote side on  17 Jan 20 17:23 MST

mybox:~ sskousen$ export USER=ubuntu; tsh ssh teleport-dev-proxyA
sskousen@teleport-dev-proxyA:~$ logout
the connection was closed on the remote side on  17 Jan 20 17:23 MST

mybox:~ sskousen$ USER=ubuntu ; tsh ssh teleport-dev-proxyA
sskousen@teleport-dev-proxyA:~$ logout
the connection was closed on the remote side on  17 Jan 20 17:24 MST

mybox:~ sskousen$ tsh ssh ubuntu@teleport-dev-proxyA
ubuntu@teleport-dev-proxyA:~$ logout
the connection was closed on the remote side on  17 Jan 20 17:24 MST

mybox:~ sskousen$ echo $USER
ubuntu
mybox:~ sskousen$

After some research, it turns out that the correct environment variable to use is actually TELEPORT_LOGIN - I’ve tried this and it seems to work fine. Hopefully it does for you too!

That does it, thank you!

1 Like