docker-sshdDocker容器的sshd代理

联合创作 · 2023-09-27 14:01

docker-ssh 可以让你直接 ssh 到 docker 容器里边 并且不需要 容器 启动 sshd

+-------------+                                                                 
|             |    ssh CONTAINER1@docker-sshd      +--------------------+       
|     ops     +------------------------------------>                    |       
|             |                                    |    docker-sshd     |       
+-------------+                                    |                    |       
                                                   +----------------+---+       
                                                                    |           
                                                                    |           
                              docker exec -ti CONTAINER1 /bin/bash  |           
                                                                    |           
                +--------------------------------------------------------------+
                |                                                   |          |
                | Docker   +------------+  +------------+    +------v-----+    |
                |          |            |  |            |    |            |    |
                |          | CONTAINER3 |  | CONTAINER2 |    | CONTAINER1 |    |
                |          |            |  |            |    |            |    |
                |          +------------+  +------------+    +------------+    |
                |                                                              |
                +--------------------------------------------------------------+

安装

 

go get github.com/tg123/docker-sshd

 

 

例子

 

  1. 启动一个 叫 CONTAINER1的容器

    docker run -d -t --name CONTAINER1 ubuntu top
    bd78d93154cff5e8b40d19b1676670a49f582d2522384ecfe0d9e7d60846891e
  2. 运行docker-sshd

    $GOPATH/bin/docker-sshd
  3. 使用 CONTAINER1 作为用户名链接 就可以使用了

    ssh CONTAINER1@127.0.0.1 -p 2232
    root@bd78d93154cf:/#

 

浏览 7
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报