Connect to docker container through host via ssh without RemoteCommand
0
votes
0
answers
41
views
I have a server that runs multiple docker containers. I can access my server via SSH, and have set up my
ssh_config
to allow me to ssh into certain containers that I regularly access:
Host some_container
HostName my.server.com
RemoteCommand docker compose -f /docker-compose.yml exec some_container fish
RequestTTY force
However, I now need to use a particular piece of software that uses ssh, and access my containers with it. This software sets the ssh command argument. Using the above configuration, this causes ssh to error out with Cannot execute command-line and remote command
, due to the presence of RemoteCommand
.
I do NOT want to have to run an sshd server inside the container.
I have attempted to replace RemoteCommand
with ProxyCommand
, but this reusults in me connecting to my server and the docker command being ignored:
ProxyCommand ssh %h -W %h:%p \
-o "RequestTTY=force" \
-o "SessionType=default" \
-o "RemoteCommand=docker compose -f /docker-compose.yml exec some_container fish"
(note that this is all one line in my ssh_config
- I have split it up here to make it easier to read).
Is there any way to ssh into my docker container without running sshd
in the container or using RemoteCommand
?
Asked by Gunnar Knutson
(1 rep)
Jul 2, 2025, 08:23 PM
Last activity: Jul 3, 2025, 03:46 AM
Last activity: Jul 3, 2025, 03:46 AM