butlerx
f2dcdb4bd2
|
7 years ago | |
---|---|---|
bin | 7 years ago | |
docs | 7 years ago | |
lib | 7 years ago | |
public | 7 years ago | |
src | 7 years ago | |
.dockerignore | 7 years ago | |
.eslintignore | 7 years ago | |
.eslintrc.js | 7 years ago | |
.gitignore | 7 years ago | |
.npmignore | 7 years ago | |
.prettierrc.js | 7 years ago | |
Dockerfile | 7 years ago | |
LICENSE | 8 years ago | |
README.md | 7 years ago | |
docker-compose.yml | 7 years ago | |
index.js | 7 years ago | |
package.json | 7 years ago | |
terminal.png | 11 years ago | |
webpack.config.js | 7 years ago | |
yarn.lock | 7 years ago |
README.md
WeTTy = Web + TTy
Terminal over HTTP and https. WeTTy is an alternative to ajaxterm and anyterm but much better than them because WeTTy uses xterm.js which is a full fledged implementation of terminal emulation written entirely in JavaScript. WeTTy uses websockets rather then Ajax and hence better response time.
This fork was originally bug fixes and updates, but has since evolved in to a full rewrite to use xterm.js to have better support and make it more maintainable.
Install
WeTTy can be installed from source or from npm. To install from source run:
$ git clone https://github.com/butlerx/wetty
$ cd wetty
$ yarn
or install it globally with yarn, yarn -g add wetty.js
, or npm,
npm i -g wetty.js
Running WeTTy
Wettu can either be run as a standalone service or from another node script. To see how to use WeTTy from node see the API Doc
$ node index.js
Open your browser on http://yourserver:3000/
and you will prompted to login.
Or go too http://yourserver:3000/ssh/<username>
to specify the user before
hand.
Flags
WeTTy can be run with the --help
flag to get a full list of flags.
WeTTy runs on port 3000
by default. You can change the default port by tunning
with the --port
or -p
flag.
If WeTTy is run as root while the host is set as the local machine it will use
the login
binary rather than ssh. If no host is specified it will use
localhost
as the ssh host.
If instead you wish to connect to a remote host you can specify the host with
the --sshhost
flag and pass the IP or DNS address of the host you want to
connect to.
You can specify the default user used to ssh to a host using the --sshuser
.
This user can overwritten by going to http://yourserver:3000/ssh/<username>
.
If this is left blank a user will be prompted to enter their username when they
connect.
By default WeTTy will try to ssh to port 22
, if your host uses an alternative
ssh port this can be specified with the flag --sshport
.
https
Always use https especially with a terminal to your server. You can add https by either using WeTTy behind a proxy or directly.
If you don't have SSL certificates from a CA you can create a self signed certificate using this command:
$ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 30000 -nodes
To run WeTTy directly with ssl use both the --sslkey
and --sslcert
flags and
pass them the path too your cert and key as follows:
node index.js --sslkey key.pem --sslcert cert.pem -p 3000
Behind a Proxy
As said earlier you can use a proxy to add https to WeTTy.
Note that if your proxy is configured for https you should run WeTTy without SSL
Nginx
Put the following configuration in nginx's conf:
location /wetty {
proxy_pass http://127.0.0.1:3000/wetty;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 43200000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
Apache
Put the following configuration in apache's conf:
RewriteCond %{REQUEST_URI} ^/wetty/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /wetty/socket.io/(.*) ws://localhost:3000/wetty/socket.io/$1 [P,L]
<LocationMatch ^/wetty/(.*)>
DirectorySlash On
Require all granted
ProxyPassMatch http://127.0.0.1:3000
ProxyPassReverse /wetty/
</LocationMatch>
Dockerized Version
WeTTy can be run from a container to ssh to a remote host or the host system.
This is handy for quick deployments. Just modify docker-compose.yml
for your
host and run:
$ docker-compose up -d
Visit the appropriate URL in your browser
([localhost|$(boot2docker ip)]:PORT
).
The default username is term
and the password is term
, if you did not modify
SSHHOST
In the docker version all flags can be accessed as environment variables such as
SSHHOST
or SSHPORT
.
Run WeTTy as a service daemon
Install WeTTy globally with global option:
init.d
$ sudo yarn global add wetty.js
$ sudo cp ~/.config/yarn/global/node_modules/wetty.js/bin/wetty.conf /etc/init
$ sudo start wetty
systemd
$ yarn global add wetty.js
$ cp ~/.config/yarn/global/node_modules/wetty.js/bin/wetty.service ~/.config/systemd/user/
$ systemctl --user enable wetty
$ systemctl --user start wetty
This will start WeTTy on port 3000. If you want to change the port or redirect
stdout/stderr you should change the last line in wetty.conf
file, something
like this:
exec sudo -u root wetty -p 80 >> /var/log/wetty.log 2>&1
FAQ
What browsers are supported?
WeTTy supports all browsers that xterm.js supports.