DEV Community

Cover image for 5-minute SSH proxy setup in a container environment
Ivan Khramov
Ivan Khramov

Posted on

5-minute SSH proxy setup in a container environment

I’ll tell you how to pull an ssh from Docker Hub to a docker platform and launch proxy using a couple commands. I did this with Containerum, but I believe the process is more or less the same for other docker platforms, too.

Basically, what you need to do is pull the SSH image from Docker Hub and deploy it in a container. Then you need to expose the SSH and pull proxy from GitHub. And then you just run your proxy from the inside of the SSH container.

In this tutorial I used Containerum CLI (https://github.com/containerum/chkit) so keep in mind that commands are platform-specific and vary slightly depending on what platform you are using.

  • First, in my case I had to download and install Containerum CLI (chkit). Then login with ```

chkit login


* Create a container with Debian image
Enter fullscreen mode Exit fullscreen mode

chkit run debian --image hklcf/debian-ssh-docker --port 22 --port 8989 --memory 512Mi --cpu 400m

22 and 8989 are ports here
![](https://thepracticaldev.s3.amazonaws.com/i/yai2lgqh56bjpk1174oq.png)

* Expose your debian container and a port for your proxy 
Enter fullscreen mode Exit fullscreen mode

chkit expose deploy debian -p ssh:22:TCP -p proxy:8989:TCP


* Check the mapping ports with
Enter fullscreen mode Exit fullscreen mode

chkit get svc

 As you can see, 22 is mapped to 34441. And 8989 is mapped to 27471.
![](https://thepracticaldev.s3.amazonaws.com/i/w9wlu5e7tqv5zziepzf4.png)

* Next - login to SSH. To do so, enter your IP and port of the service - in the case above our IP is x3.containerum.io, SSH port is 34441. The default user and password for this image is “root / password”

* Update the system and install wget with
```sh


apt-get update && apt install wget


Enter fullscreen mode Exit fullscreen mode
  • Then install proxy with ```sh

wget --no-check-certificate -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh && \
chmod +x shadowsocks-all.sh && ./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log

![](https://thepracticaldev.s3.amazonaws.com/i/0lw7z2dkyfcjaeqlgbse.png)
* Finally, configure your proxy server and your shadowsocks client and enjoy!

P.S. If you have any questions or know a better way to launch an SSH proxy server in containers, comment below!
Enter fullscreen mode Exit fullscreen mode

Top comments (4)

Collapse
 
pcornelissen profile image
Patrick Cornelißen

Creating snowflake Containers is even worse than creating snowflake servers.

Why didn't you create a dockerfile that does the job? :-)

Collapse
 
mastanggt profile image
Ivan Khramov

Hi, Patrick.
I just wanted to show the logic of launching it this way. Sure, you can write a dockerfile or use another image.
Maybe I'll do it later and share the dockerfile here.

Cheers,

Collapse
 
pcornelissen profile image
Patrick Cornelißen

The danger of these articles is that people with no or just a little docker knowledge will take this as a how-to and end up with getting the wrong impression. Of course what you wrote is not wrong and is OK to find out what needs to be done. But it's crucial that you script that knowledge in a dockerfile or script file afterwards. Otherwise you will end up doing the same over and over again and even worse maybe forget what needs to be done and you have to rediscover it again.

Collapse
 
vlasov_white profile image
Александр Власов

Highly exhaustively, thanks