---
title: Charmhub | Deploy Tmate-ssh-server using Charmhub - The Open Operator Collection
description: Deploy the latest version of Tmate-ssh-server on any cloud.
url: https://charmhub.io/tmate-ssh-server/docs/tutorial-getting-started
---

# Tmate-ssh-server

[Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

* [Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

Platform:

24.04

22.04

stable 76324872

```
juju deploy tmate-ssh-server
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

---

#### Contacts

##### Maintainers

+ [Launchpad Team](https://launchpad.net/~canonical-is-devops)

* [Submit a bug](https://github.com/canonical/tmate-ssh-server-operator/issues)

---

Share your thoughts on this charm with the community on discourse.

[Join the discussion](https://discourse.charmhub.io/)

# Deploy the tmate SSH server charm for the first time

## [What you’ll do](https://charmhub.io/tmate-ssh-server/docs/tutorial-getting-started#p-29806-what-youll-do)

* Deploy the [tmate SSH server charm](https://charmhub.io/tmate-ssh-server)
* Get the `.tmate.conf` through `get-server-config` action
* Create a tmate client machine and configure tmate client
* SSH into tmate terminal

Tmate is a remote terminal sharing tool that allows users to securely share their terminal with
others in real-time, making it easy to collaborate, troubleshoot, and provide support across
different systems and networks. It provides a seamless way to establish SSH connections and enables
remote access without requiring complex network configurations.

## [Requirements](https://charmhub.io/tmate-ssh-server/docs/tutorial-getting-started#p-29806-requirements)

To deploy a tmate SSH server charm, you will need a Juju controller bootstrapped with any machine
controller type.
To see how to bootstrap your Juju installation with LXD, please refer to the documentation
on LXD [installation](https://juju.is/docs/juju/lxd).

## [Steps](https://charmhub.io/tmate-ssh-server/docs/tutorial-getting-started#p-29806-steps)

### [Set up the tutorial model](https://charmhub.io/tmate-ssh-server/docs/tutorial-getting-started#p-29806-set-up-the-tutorial-model)

To easily clean up the resources and to separate your workload from the contents of this tutorial,
set up a new model with the following command.

```
juju add-model tmate-tutorial
```

### [Deploy the tmate SSH server charm](https://charmhub.io/tmate-ssh-server/docs/tutorial-getting-started#p-29806-deploy-the-tmate-ssh-server-charm)

Use the following command to deploy the tmate SSH server charm.

```
juju deploy tmate-ssh-server
```

### [Get the tmate configuration contents](https://charmhub.io/tmate-ssh-server/docs/tutorial-getting-started#p-29806-get-the-tmate-configuration-contents)

To register a tmate client, we need a file containing the configuration details.
Use the `get-server-config` action to retrieve the details, and save the output contents
into `.tmate.conf` for later use.

```
juju run tmate-ssh-server/0 get-server-config | grep -E set | sed 's/^[[:space:]]*//' > .tmate.conf
```

The output of `.tmate.conf` file generated from the previous command will look something like the following:

```
set -g tmate-server-host <tmate-ssh-server-unit-ip>
set -g tmate-server-port 10022
set -g tmate-server-rsa-fingerprint <rsa-fingerprint>
set -g tmate-server-ed25519-fingerprint <ed25519-fingerprint>
```

### [Create a tmate client machine](https://charmhub.io/tmate-ssh-server/docs/tutorial-getting-started#p-29806-create-a-tmate-client-machine)

To imitate a tmate client, we can add a machine on Juju and install tmate.

```
juju add-machine
juju ssh 1 -- "sudo apt update && sudo apt install -y tmate"
```

Copy the `.tmate.conf` file we previously created to the client
machine.

Then, register the public key of the current machine (use `ssh-keygen` to generate key files if
none exist yet).

```
juju scp .tmate.conf 1:~/.tmate.conf
juju ssh 1 -- "echo $(~/.ssh/id_rsa.pub) >> ~/.ssh/authorized_keys"
```

Start the tmate client and get the SSH command.

```
# start a new tmate session
juju ssh 1 -- "tmate -a ~/.ssh/authorized_keys -S /tmp/tmate.sock new-session -d"
# wait until the tmate session is ready
juju ssh 1 -- "tmate -S /tmp/tmate.sock wait tmate-ready"
# print tmate ssh details
juju ssh 1 -- "tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}'"
# output looks something like ssh -p10022 <user>@0.0.0.0
```

### [SSH into the tmate terminal](https://charmhub.io/tmate-ssh-server/docs/tutorial-getting-started#p-29806-ssh-into-the-tmate-terminal)

Run `juju status` command to find out the unit IP address.

```
Model           Controller  Cloud/Region         Version  SLA          Timestamp
tmate-tutorial  localhost   localhost/localhost  3.1.6    unsupported  <timestamp>

App               Version  Status  Scale  Charm             Channel  Rev  Exposed  Message
tmate-ssh-server           active      1  tmate-ssh-server             0  no

Unit                 Workload  Agent  Machine  Public address  Ports  Message
tmate-ssh-server/0*  active    idle   0        <unit-ip>

Machine  State    Address              Inst id        Base          AZ  Message
0        started  <unit-ip>            juju-92dc13-0  ubuntu@22.04      Running
1        started  <client-machine-ip>  juju-92dc13-1  ubuntu@22.04      Running
```

Then use the ssh command output from the previous step and replace `0.0.0.0` address to the unit
IP of tmate-ssh-server unit.

```
ssh <user>@<unit-ip>
```

The output will look something like the following:

```
Tip: if you wish to use tmate only for remote access, run: tmate -F
To see the following messages again, run in a tmate session: tmate show-messages
Press <q> or <ctrl-c> to continue
---------------------------------------------------------------------
Connecting to <unit-ip>...
Note: clear your terminal before sharing readonly access
ssh session read only: ssh -p10022 ro-<ro-user>@<unit-ip>
ssh session: ssh -p10022 <user>@<unit-ip>
```

### [Clean up the environment](https://charmhub.io/tmate-ssh-server/docs/tutorial-getting-started#p-29806-clean-up-the-environment)

Congratulations! You have successfully finished the tmate SSH server tutorial. You can now remove
the `.tmate.conf` file and the Juju model environment that you’ve created using the following
command.

```
rm .tmate.conf
juju destroy-model tmate-tutorial -y
```

---
