Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to connect tmate client #303

Open
agrawawl-ric opened this issue May 20, 2024 · 0 comments
Open

Not able to connect tmate client #303

agrawawl-ric opened this issue May 20, 2024 · 0 comments

Comments

@agrawawl-ric
Copy link

I have created tmate-ssh-server on docker container with the below docker file:

  • Dockerfile:

tmateserver@tmateserver:~$ vi Dockerfile
apt-get install -y build-essential cmake libmsgpack-dev libssl-dev
libssh-dev libutempter-dev zlib1g-dev wget openssh-server autoconf
automake libtool pkg-config libevent-dev libncurses-dev

Download and install tmate

Download and install tmate

RUN wget https://github.com/tmate-io/tmate/archive/2.4.0.tar.gz -O tmate.tar.gz &&
tar -zxvf tmate.tar.gz &&
cd tmate-2.4.0 &&
./autogen.sh &&
./configure &&
make &&
make install

Set up SSH server

RUN mkdir /var/run/sshd &&
echo 'root:rootpassword' | chpasswd &&
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config &&
sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config &&
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config &&
sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config

Add a user for tmate

RUN useradd -ms /bin/bash tmateuser && echo "tmateuser:tmatepassword" | chpasswd

Set up tmate

RUN mkdir -p /home/tmateuser/.tmate
COPY tmate.conf /home/tmateuser/.tmate.conf
RUN chown tmateuser:tmateuser /home/tmateuser/.tmate.conf

Expose SSH port

EXPOSE 22

Start SSH and tmate

#CMD ["/usr/sbin/sshd", "-D"]

Start SSH and tmate

CMD service ssh start && tail -f /dev/null

  • Created tmate.conf file in host machine tmate.conf:
    set -g tmate-server-host 127.0.0.1
    set -g tmate-server-port 2222
    set -g tmate-ssh-port 2222

Step 2: Build and Run the Docker Container
Build the Docker image:
docker build -t tmate-server .

- Run the Docker container:
docker run -d -p 2222:2222 --name tmate-server-container tmate-server

Step 3: Configure SSH Access and Key Authentication
Generate an SSH key on the host machine :

ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa -N ""
Copy the public key to the container's authorized_keys for tmateuser:
docker cp ~/.ssh/id_rsa.pub tmate-server-container:/home/tmateuser/id_rsa.pub
docker exec -it tmate-server-container bash
mkdir -p /home/tmateuser/.ssh
cat /home/tmateuser/id_rsa.pub >> /home/tmateuser/.ssh/authorized_keys
chown -R tmateuser:tmateuser /home/tmateuser/.ssh
chmod 600 /home/tmateuser/.ssh/authorized_keys
exit

Step 4: Connect Using the Tmate Client
On the host machine, create a Tmate session and connect to the Tmate server:
tmate -S /tmp/tmate.sock new-session -d
tmate -S /tmp/tmate.sock wait tmate-ready
tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}'

Step no.4 is not giving output
tmate -S /tmp/tmate.sock wait tmate-ready-----------This command takes forever
tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}'-------------This command give no output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant