https://github.com/huashengdun/websshnginx
先安装docker和docker-compose,详细不说了git
git clone https://github.com/huashengdun/webssh.git
第一次运行会须要时间下载各类包,时间大概10分钟 第二次直接运行,大概2秒github
cd webssh docker-compose up #或者后台运行 docker-compose up -d
若是没有配置nginx,那不用看访问限制那段了,直接用ip加8888端口便可访问到页面 例如我这台服务器的ip是10.2.10.52,那我只要再浏览器里输入http://10.2.10.52:8888 就能访问到了web
访问xxx.xxx.com便可,nginx内部会将请求转给webssh的,具体要看nginx如何配置了
具体参考下面的访问限制段落docker
因为ssh的敏感性,webssh只监听私有网段的ip,若是用公网ip访问则拒绝 若是想用公网也能访问,前面放个nginx便可浏览器
server { listen 80; server_name xxx.xxx.com; auth_basic "who"; auth_basic_user_file /etc/nginx/userpassword.db; location / { proxy_http_version 1.1; proxy_read_timeout 300; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_pass http://10.2.10.52:8888; } }
注意这里的proxy_pass用的是内网ip,而不是127.0.0.1,是由于我这个nginx也是跑在docker里的 若是nginx是跑在本机里,能够用127.0.0.1的服务器
另外我多作了个认证ssh
auth_basic "who"; auth_basic_user_file /etc/nginx/userpassword.db;
若是不作认证,全部知道url的人均可以拿你这个ssh客户端用了url