D
D
DenZel2020-01-13 10:17:19
LXC
DenZel, 2020-01-13 10:17:19

How to ssh into a docker container?

Hi all.
- installed the ssh service in the container
- forwarded the container port 22 to the host
- added permission to connect root to the container in the ssh_config of the container
- I try to connect remotely via ssh, after entering the password it says: permission deny ......
Tell me what could be the problem ? What else do you need to forward to the container besides the port to access it via ssh ?
Thanks

Answer the question

In order to leave comments, you need to log in

6 answer(s)
G
Georg Gaal, 2020-02-02
@gen4_gdm

This task appeared in connection with the launch of gitlab in a docker container.
There were two solutions:

  1. Allocate an additional IP address to the host, configure host ssh to the main ip, and give the additional one to gitlab services (ports 22, 443, 80)
  2. the second option is to use ssh proxy. Like this . The point is that when connecting to the host machine under the credentials of a specific user (git), all traffic is directed to the container. All other users connect directly to the host machine and a shell is opened for them on it

D
display: block, 2020-01-13
@qork

#PasswordAuthentication yesuncommented in ssh config?
Why not use docker exec instead of ssh?
https://docs.docker.com/engine/reference/commandli...

I
ISE73, 2020-01-15
@ISE73

If you are trying to connect to a container in Docker via SSH, then you are somehow trying to use Docker in a wrong way.
Why do you need to go there via SSH?

S
Sergey Sokolov, 2020-01-13
@sergiks

Folder .sshwith keys from the home directory connected to the container?

docker run \
  -v "$HOME/.ssh":/root/.ssh:ro
  ...

D
DenZel, 2020-01-15
@gen4_gdm

After studying, I realized that the best solution is to use supervisor.

A
Anatoly Soldatov, 2020-03-06
@soldatov

Did it work out in the end?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question