0

My setup is Linux host with SSH and SFTP access. It runs inside a docker container exposing also SSH and SFTP. The docker container does not have a separate network. Uses “host” network setting.

I want to make it possible to access docker container via SFTP from a remote machine. When I access using SFTP port 2222, it connects to the host but not to the docker.

How I configure both host and container in a such way that I can access container from remote machine using SFTP?

3
  • Can you please re-write the question, adding some clarity? So you want the host to listen to both 22 and 2222, and only forward ssh to 22 to 2222 in the container? What is the reason for doing that, can you please describe what you're architecture is, and what you're trying to achieve with it as an end result, rather than just asking how do a set thing? Commented Jan 4 at 4:29
  • Rephrased question Commented Jan 4 at 9:34
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Jan 9 at 13:56

2 Answers 2

0

Check out the --publish option to the docker run command, e.g., --publish 2222:22 if your container's sshd is configured on the default port. This listens on the host on port 2222, and forwards connections to port 22 within your container. If you've already configured your container's sshd to listen on 2222 (which is not necessary), use --publish 2222:2222 but if you've done this, I'd recommend reverting it to 22 and using the first form.

0

The solution is to use another sshd instance which solved me the problem. The single one configuration is overridden by Lima so it didn’t work well as one would expect to be.

Added to cron @restart sshd -f myconfig

Solved the problem.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.