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

ssh to localhost fails with "Connection closed by 127.0.0.1 port 4444" #172

Open
yuvalatzmon opened this issue Dec 14, 2023 · 1 comment

Comments

@yuvalatzmon
Copy link

Hello,

I'm having trouble SSHing into a container. Here's a simplified example using ssh to localhost:

enroot import 'docker://nvcr.io#nvidia/pytorch:23.10-py3' && enroot create --name torch2310 nvidia+pytorch+23.10-py3.sqsh && enroot start --root --rw torch2310 /bin/bash -c 'cd ~ && mkdir -p ~/.ssh && apt update && apt install openssh-server sudo -y && echo "PermitRootLogin yes" >> /etc/ssh/sshd_config && echo "AuthorizedKeysFile .ssh/authorized_keys" >> /etc/ssh/sshd_config && echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config && echo "LogLevel VERBOSE" >> /etc/ssh/sshd_config && echo "GatewayPorts yes" >> /etc/ssh/sshd_config && echo "Port 4444" >> /etc/ssh/sshd_config && service ssh restart && ssh-keygen -q -N "" -f /root/.ssh/id_rsa && cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys && ssh -o StrictHostKeyChecking=no -p 4444 localhost echo SUCCESS'

SSHing to localhost fails with the error message

Connection closed by 127.0.0.1 port 4444.

The same command runs successfully using a docker container

docker run --net=host -v --rm -it nvcr.io/nvidia/pytorch:23.10-py3 /bin/bash -c 'cd ~ && mkdir -p ~/.ssh && apt update && apt install openssh-server sudo -y && echo "PermitRootLogin yes" >> /etc/ssh/sshd_config && echo "AuthorizedKeysFile .ssh/authorized_keys" >> /etc/ssh/sshd_config && echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config && echo "LogLevel VERBOSE" >> /etc/ssh/sshd_config && echo "GatewayPorts yes" >> /etc/ssh/sshd_config && echo "Port 4444" >> /etc/ssh/sshd_config && service ssh restart && ssh-keygen -q -N "" -f /root/.ssh/id_rsa && cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys && ssh -o StrictHostKeyChecking=no -p 4444 localhost echo SUCCESS'

Warning: Permanently added ‘[localhost]:4444’ (ECDSA) to the list of known hosts.
SUCCESS

@3XX0
Copy link
Member

3XX0 commented Dec 14, 2023

See #92

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

2 participants