Skip to content

Instantly share code, notes, and snippets.

@oudam-meas
Forked from xinzweb/tmate-slave-ubuntu-1604.md
Last active January 14, 2019 06:25
Show Gist options
  • Save oudam-meas/baa2822ea340bd017a03f6e1160edf4d to your computer and use it in GitHub Desktop.
Save oudam-meas/baa2822ea340bd017a03f6e1160edf4d to your computer and use it in GitHub Desktop.
Tmate-slave on Ubuntu 18

Install dependincies

apt-get install  git-core build-essential pkg-config libtool libevent-dev libncurses-dev zlib1g-dev automake libssh-dev cmake ruby

Install msgpack >= 1.2.0

git clone https://github.com/msgpack/msgpack-c.git
cd msgpack-c
cmake .
make
sudo make install

Install newer libssh >= 0.7.0

sudo add-apt-repository ppa:kedazo/libssh-0.7.x
sudo apt-get update
sudo apt-get install libssh-4

Compile tmate-slave

git clone https://github.com/tmate-io/tmate-slave.git
cd tmate-slave
./autogen.sh
./configure
make

When run ./configure and If you encounter libssh not found on Ubuntu 18!

Error: configure: error: "libssh >= 0.7.0 not found"

Solution: tmate-io/tmate-ssh-server#21 (comment)

git clone [email protected]:msgpack/msgpack-c.git
cd msgpack-c ; ./configure --prefix=~/artifacts ; make install
git clone git://git.libssh.org/projects/libssh.git
mkdir tmp-build ; cd tmp-build
cmake -DCMAKE_INSTALL_PREFIX=~/artifacts -DCMAKE_BUILD_TYPE=Release ../libssh
make install

Then prepare PKG_CONFIG_PATH for tmate-slave build

export PKG_CONFIG_PATH=~/artifacts/lib/pkgconfig/

Then continue where you left off by running

./configure
make

Run tmate-slave

# NOW, tmate-slave is ready, let's run it and listen to port 2222. 

# This will generate SSH keys, REMEMBER the keys fingerprints, you need those later in `~/.tmate.conf` settings
# Those keys are stored under directory ./keys
./create_keys.sh
sudo sighup ./tmate-slave -p 2222 -k /etc/tmate-slave-keys

Then follow the instruction from https://tmate.io/ of the "Host your own tmate server" to setup the ~/.tmate.conf to use your own tmate-slave server on Ubuntu.

Make the tmate-slave run as a service

Setup systemd (/etc/systemd/system/tmate-slave.service)

[Install]
WantedBy=multi-user.target

[Unit]
Description=Tmate-Slave
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
Restart=always
User=root
ExecStart=/home/ubuntu/tmate-slave/tmate-slave -p 2222 -k /home/ubuntu/tmate-slave/keys

Enable/Start service

sudo systemctl daemon-reload
sudo systemctl enable tmate-slave
sudo systemctl start tmate-slave

You can check the status using systemctl status tmate-slave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment