Skip to content

Instantly share code, notes, and snippets.

@paigeadelethompson
Last active December 8, 2022 03:40
Show Gist options
  • Save paigeadelethompson/4ae6d176bd2b9b95f2269c3fed81ec4b to your computer and use it in GitHub Desktop.
Save paigeadelethompson/4ae6d176bd2b9b95f2269c3fed81ec4b to your computer and use it in GitHub Desktop.
Tmate setup with docker
# substitute apt or yum or zypper for brew for whichever operating system you're on
brew install tmate
cd ~
git clone https://github.com/tmate-io/tmate-ssh-server.git
cd tmate-ssh-server
docker build -t tmate/tmate-ssh-server -t tmate/tmate-ssh-server:latest .
cd ~
mkdir tmate
cd tmate
curl -s -q https://raw.githubusercontent.com/tmate-io/tmate-ssh-server/master/create_keys.sh | bash | grep "^set " | tee ~/.tmate.conf
cd ~
# then just edit the ~/.tmate.conf and set:
# change tmate-server-port 22
# to
# tmate-server-port 2222
#
# if you have docker running on a VPS somewhere, change localhost to the ip of your VPS for:
#
# tmate-server-host localhost
#
# to
#
# tmate-server-host aa.bb.cc.dd
#
# also upload the ~/tmate/ directory to the VPS user's home dir then run the docker command on the VPS:
docker run -it --name my_tmate --restart always -d --cap-add SYS_ADMIN -v $HOME/tmate:/tmate:ro -e "SSH_KEYS_PATH=/tmate/keys" -e "SSH_PORT_LISTEN=22" -p 2222:22 tmate/tmate-ssh-server
docker ps -a
# just run tmate now:
tmate
should look like:
Tip: if you wish to use tmate only for remote access, run: tmate -F [0/0]
To see the following messages again, run in a tmate session: tmate show-messages
Press <q> or <ctrl-c> to continue
---------------------------------------------------------------------
Connecting to localhost...
Note: clear your terminal before sharing readonly access
ssh session read only: ssh ro-QGyQjwyc8X76QQk4bfb3MksPw@0a9378e015a8
ssh session: ssh HUTzwWXP3W3vVxGrMUCpnvxXZ@0a9378e015a8
check logs with
docker logs my_tmate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment