How to Connect to Teleport from Windows Client Pre and Post Teleport 6.1.x #7164
Replies: 1 comment
-
With To generate, simply login to your proxy ( With release 7.2, you no longer need to install OpenSSH for |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Assumptions:
User
. If your Windows username is different, please replaceUser
with your own username throughout these examples.teleport.example.com
is the name of the Teleport proxy server - please change this to your own server.examplehost
- please change this to the name of the host you actually wish to access.Requirements:
Assumptions:
User
. If your Windows username is different, please replaceUser
with your own username throughout these examples.teleport.example.com
is the name of the Teleport proxy server - please change this to your own server.examplehost
- please change this to the name of the host you actually wish to access.Requirements:
Installing the OpenSSH client
Firstly, you'll need to install the OpenSSH client by following the instructions from Microsoft here: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
Once this is done, when you open Command Prompt and type
ssh.exe
you should get some output describing how to use thessh
command:Downloading the Teleport client -
tsh.exe
Once this is done, download the latest version of Teleport for Windows from https://goteleport.com/teleport/download - you're looking for the one titled "
Windows (64-bit, tsh client only)".
This will download a ZIP file. Open the ZIP file, open the "teleport" directory and find the "tsh.exe" file - you should copy this file to
C:\Users\User
so that it's easily accessible when opening a Command Prompt.Logging into a Teleport cluster
To authenticate with Teleport, you'll need to run
tsh.exe login --proxy=teleport.example.com
and follow the authentication flow. Once done, you should get some output:Logging into the Teleport cluster will saves your SSH certificate to your local machine under
C:\Users\User\.tsh\keys\teleport.example.com
- let's look at the contents of this directory.Pre-6.1.x this directory should look something like this:
In this directory setup,
exampleuser
is the private key andexampleuser-cert.pub
is the SSH certificate encapsulating our user identity. We'll need to use these files when connecting to other hosts via Teleport.Post-6.1.x this directory should look something like this:
In this directory setup,
exampleuser
is the private key. If we go one layer deeper into theexampleuser-ssh
directory we will also find anteleport.example.com-cert.pub
cert file, which is the SSH certificate encapsulating our user identity. We'll need to use these files when connecting to other hosts via Teleport.Making an SSH connection
Here's an example command using Teleport as an SSH proxy/bastion host:
ssh.exe -i C:\Users\User\.tsh\keys\teleport.example.com\exampleuser -o "ProxyCommand=ssh.exe -i C:\Users\User\.tsh\keys\teleport.example.com\exampleuser -p 3023 [email protected] -s proxy:%h:%p" unixuser@examplehost -p 3022
Here's what happens when you run it:
For the curious, let's break down the different parts of this command and what they do.
-i C:\Users\User\.tsh\keys\teleport.example.com\exampleuser
: tells SSH to use this file as the identity to connect to the remote host (examplehost
) - as this is a private key associated with an SSH certificate, SSH will automatically also use theexampleuser-cert.pub
file here in the background.-o "ProxyCommand=ssh.exe -i C:\Users\User\.tsh\keys\teleport.example.com\exampleuser
: sets up a command that will be run before the main SSH connection as aProxyCommand
-p 3023
: the SSH connection for theProxyCommand
should connect to port 3023 (Teleport's SSH proxy service)[email protected]
: The system username and proxy hostname to connect to for theProxyCommand
. This system username must be one that you're allowed to use to log in with Teleport - see theLogins:
field in the output oftsh login
ortsh status
for usernames you can use.-s proxy:%h:%p"
: when connected to the proxy host, invoke theproxy
subsystem.%h
is automatically replaced with the hostname of the remote host as (examplehost
in this case) and%p
is automatically replaced with the target port for the remote host connection (3022
in this case)unixuser@examplehost
: The system username and hostname to connect to after making the proxy connection - this is the host your shell will actually be connected to once the SSH command runs.-p 3022
: The port listening for SSH connections on the remote host - this is the default port for the Teleport 'node' service.Using the SSH config file
The SSH command above is very long and complicated, so typing or copying this every time you want to connect to a host will get old quickly. You can tell SSH to automatically apply a configuration whenever you connect to a certain host by editing the SSH client configuration file, found at
C:\Users\User\.ssh\config
Here's an example of how to automatically apply our settings from the command line via the SSH client config file:
When this file is saved to
C:\Users\User\.ssh\config
, SSH will automatically read it and apply the settings before connecting. This means that instead of typing the long-windedssh -i "C:\Users\User\.tsh\keys\teleport.example.com\exampleuser" -o "ProxyCommand=ssh.exe -i C:\Users\User\.tsh\keys\teleport.example.com\exampleuser -p 3023 [email protected] -s proxy:%h:%p" unixuser@examplehost -p 3022
, you can typessh examplehost
instead:When this file is saved to
C:\Users\User\.ssh\config
, SSH will automatically read it and apply the settings before connecting. This means that instead of typing the very long-windedssh -i "C:\Users\User\.tsh\keys\teleport.example.com\exampleuser" -o "ProxyCommand=ssh.exe -i C:\Users\User\.tsh\keys\teleport.example.com\exampleuser -p 3023 [email protected] -s proxy:%h:%p" unixuser@examplehost -p 3022
, you can typessh examplehost
instead:Much shorter!
Advanced use cases: ssh-agent
If you start the OpenSSH authentication agent service on your Windows machine, this will automatically receive certificates from Teleport so that you don't need to explicitly specify an identity file each time you connect.
You can start ssh-agent from the Windows services menu -
services.msc
This can be useful if you need to connect onward from
examplehost
to other machines and still want to use your SSH identity.This can be useful if you need to connect onward fromexamplehost
to other machines and still want to use your SSH identity. You can use the-A
command line argument tossh
to forward yourssh-agent
identity on to the server you connect to, or specifyForwardAgent yes
in your.ssh/config
file.Advanced use cases: IdentitiesOnly
If we want to specify and limit which keys your SSH client should look for (this can be useful in cases of being logged into multiple clusters simultaneously), we can pass the
IdentitiesOnly
flag along with theIdentityFile
flag either in the SSH command or via config. Starting with Teleport 6.1.x we will want to specify the full path to the cert and not the private key as we did in the example above. Below is an example of how this would look like in an updated SSH config:Beta Was this translation helpful? Give feedback.
All reactions