什么是sshwifty
Sshwifty is a SSH and Telnet connector made for the Web. It can be deployed on your computer or server to provide SSH and Telnet access interface for any compatible (standard) web browser.Github
介绍
通过Heroku搭建WebSSH服务sshwifty,Heroku是免费容器服务(severless),sshwifty是网页版SSH服务。可以实现任意浏览器连接linux服务器(仅支持ipv4)
部署方式
官方提供多种安装方式,本文使用Heroku容器搭建,其他方式请参考原作者Github
安装前的必备环境
- Linux(测试机为Ubuntu 18.04.5 LTS,理论上任何发行版都支持)
- git,node,npm,Heroku CLI
安装git,node,npm,Heroku CLI
#安装git
$ yum install git //Centos
$ apt-get install git //Debian,Ubuntu
#安装node和npm
$ yum install nodejs //Centos
$ apt-get install nodejs //Debian,Ubuntu
$ apt-get install npm
$$如果提示npm : Depends: node-gyp (>= 0.10.9) but it is not going to be installed,使用下方命令尝试修复
$ sudo apt-get install nodejs-dev node-gyp libssl1.0-dev
$ sudo apt-get install npm
#安装Heroku CLI
$ sudo snap install --classic heroku
检查所需服务是否已经安装
$ git version
git version 2.17.1
$ node -v
v8.10.0
$ npm -v
3.5.2
$ heroku -v
heroku/7.47.11 linux-x64 node-v8.10.0
拉取源码到本地
$ git clone https://github.com/niruix/sshwifty
$ cd sshwifty
登录Heroku
$ heroku login -i
heroku: Enter your login credentials
Email: [email protected]
Password: ***************
Two-factor code: ********
Logged in as [email protected]
创建一个Heroku APP
$ cd ~/myapp
$ heroku create
Creating app... done, ⬢ sleepy-meadow-81798
https://sleepy-meadow-81798.herokuapp.com/ | https://git.heroku.com/sleepy-meadow-81798.git
使用git推送到Heroku APP
$ heroku git:remote -a sleepy-meadow-81798 //请勿照抄,填写上一步生成的App name
检查是否成功添加到远程库(有类似以下输出则成功)
$ git remote -v
heroku https://git.heroku.com/yourapp.git (fetch)
heroku https://git.heroku.com/yourapp.git (push)
origin https://github.com/niruix/sshwifty (fetch)
origin https://github.com/niruix/sshwifty (push)
将应用添加为容器
$ heroku stack:set container
推送应用到Heroku远程库并部署(测试需要较长时间)
$ git push heroku master
remote: Removing intermediate container
remote: : Pushed
remote: : Pushed
remote: : Pushed
..........
配置Heroku APP后台设置
找到刚刚部署的APP
点击Settings找到Config Vars点击reveal Config Vars显示配置
添加一个Config Vars
在 KEY 填入 SSHWIFTY_LISTENPORT ,VALUE 填入 SSHWIFTY_ENV_RENAMED:PORT 后点击Add完成添加