diff --git a/README.md b/README.md index fdce4d0..6f94cb9 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,15 @@ in docker better. - `cd wetty` - `yarn` +or + +`yarn add wetty.js` + ## Run on HTTP - node app.js -p 3000 +``` bash +node app.js -p 3000 +``` If you run it as root it will launch `/bin/login` (where you can specify the user name), else it will launch `ssh` and connect by default to @@ -34,18 +40,26 @@ SSH user using the `--sshuser` option. You can also specify the SSH user name in the address bar like this: - `http://yourserver:3000/wetty/ssh/` +`http://yourserver:3000/wetty/ssh/` + +or + +`http://yourserver:3000/ssh/` ## Run on HTTPS Always use HTTPS. 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` +``` +openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 30000 -nodes +``` And then run: - node app.js --sslkey key.pem --sslcert cert.pem -p 3000 +``` +node app.js --sslkey key.pem --sslcert cert.pem -p 3000 +``` Again, if you run it as root it will launch `/bin/login`, else it will launch SSH to `localhost` or a specified host as explained above. @@ -69,11 +83,21 @@ Put the following configuration in nginx's conf: If you are running `app.js` as `root` and have an Nginx proxy you have to use: - http://yourserver.com/wetty +``` +http://yourserver.com/wetty +``` + +Else if you are running `app.js` as a regular user you can use: + +``` +http://yourserver.com/wetty/ssh/ +``` -Else if you are running `app.js` as a regular user you have to use: +or - http://yourserver.com/wetty/ssh/ +``` +http://yourserver.com/wetty +``` **Note that if your Nginx is configured for HTTPS you should run wetty without SSL.** @@ -96,12 +120,23 @@ If you dont want to build the image yourself just remove the line `build; .` ## Run wetty as a service daemon -Install wetty globally with -g option: +Install wetty globally with global option: + +### init.d + +```bash +$ sudo yarn global add wetty.js +$ sudo cp /usr/local/lib/node_modules/wetty.js/bin/wetty.conf /etc/init +$ sudo start wetty +``` + +### systemd ```bash - $ sudo npm install wetty -g - $ sudo cp /usr/local/lib/node_modules/wetty/bin/wetty.conf /etc/init - $ sudo start wetty +$ 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 @@ -113,4 +148,4 @@ exec sudo -u root wetty -p 80 >> /var/log/wetty.log 2>&1 ## Clean-up If users dont fully disconnect when finished ssh connections will actually be kept open the simplest -way to deal with this is run `/app/bin/cleanup` on a cron job. +way to deal with this is run `bin/cleanup` on a cron job. diff --git a/bin/wetty.service b/bin/wetty.service index dd79a27..1eff15e 100644 --- a/bin/wetty.service +++ b/bin/wetty.service @@ -9,11 +9,9 @@ Description=Wetty Web Terminal After=network.target [Service] -User=root -Group=root -WorkingDirectory=/home/akadmin/pack/wetty # CHANGE ME -ExecStart=/usr/bin/node app.js -p 9123 --host 127.0.0.1 +WorkingDirectory=$HOME/.config/yarn/global/node_modules/wetty.js/ +ExecStart=/usr/bin/node app.js -p 3000 --host 127.0.0.1 [Install] WantedBy=multi-user.target diff --git a/docker-compose.yml b/docker-compose.yml index b27b66f..310fd8f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ version: "3" services: wetty: build: . - image: redbrick/wetty + image: butlerx/wetty container_name: wetty tty: true working_dir: /app diff --git a/package.json b/package.json index 477d212..0ba3a92 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "name": "wetty", - "version": "0.2.0", + "name": "wetty.js", + "version": "0.3.0", "dependencies": { "express": "^4.15.3", "optimist": "^0.6", - "pty.js": "^0.3.0", + "pty.js": "^0.3.1", "serve-favicon": "^2.4.3", "socket.io": "^1.3.7" }, @@ -21,24 +21,28 @@ "load-grunt-tasks": "^3.0" }, "description": "Wetty = Web + tty. Terminal access in browser over http/https ", - "main": "app.js", "repository": { "type": "git", - "url": "git://github.com/krishnasrinivas/wetty.git" + "url": "git://github.com/butlerx/wetty.git" }, - "author": "Krishna Srinivas (https://github.com/krishnasrinivas)", + "author": "Cian Butler (https://github.com/butlerx)", "license": "MIT", "bugs": { - "url": "https://github.com/krishnasrinivas/wetty/issues" + "url": "https://github.com/butlerx/wetty/issues" }, - "homepage": "https://github.com/krishnasrinivas/wetty", + "homepage": "https://github.com/butlerx/wetty", "preferGlobal": "true", + "main": "app.js", "bin": { "wetty": "./bin/wetty.js" }, + "files": [ + "bin", + "public" + ], "scripts": { "lint": "eslint .", - "fix": "eslint . --fix", + "lint:fix": "eslint . --fix", "build": "grunt", "start": "node app.js" }