diff --git a/.gitignore b/.gitignore index 38311e2..2e7ecaa 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,6 @@ logs results npm-debug.log +.idea node_modules/* .esm-cache diff --git a/Dockerfile b/Dockerfile index 6c7228b..6e6682e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,13 +3,15 @@ WORKDIR /usr/src/app RUN apk add --update build-base python COPY . /usr/src/app RUN yarn - FROM node:8-alpine MAINTAINER butlerx@notthe.cloud WORKDIR /app RUN adduser -D -h /home/term -s /bin/sh term && \ ( echo "term:term" | chpasswd ) && \ - apk add openssh-client + apk add openssh-client && \ + apk add sshpass +USER term EXPOSE 3000 COPY --from=builder /usr/src/app /app -CMD node bin +RUN mkdir ~/.ssh +CMD ssh-keyscan -H wetty-ssh >> ~/.ssh/known_hosts && node bin diff --git a/Dockerfile-ssh b/Dockerfile-ssh new file mode 100644 index 0000000..317de63 --- /dev/null +++ b/Dockerfile-ssh @@ -0,0 +1,3 @@ +FROM sickp/alpine-sshd:latest +RUN adduser -D -h /home/term -s /bin/sh term && \ + ( echo "term:term" | chpasswd ) \ No newline at end of file diff --git a/README.md b/README.md index de9da2e..c7040cb 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ wetty -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 `localhost`. +* `apt-get install sshpass` (debian eg. Ubuntu) for auto-login feature + +* `yum install sshpass` (red hat flavours eg. CentOs) for auto-login feature + +Run on HTTP: +----------- If instead you wish to connect to a remote host you can specify the `--sshhost` option, the SSH port using the `--sshport` option and the SSH user using the @@ -35,8 +41,26 @@ or `http://yourserver:3000/ssh/` +You can pass an optional password as query parameter to use auto-login feature. + +`http://yourserver:3000/wetty/ssh/?sshpass=` + +or + +`http://yourserver:3000/ssh/?sshpass=` + + ## Run on HTTPS +You can also pass the SSH user name and password as query parameters and auto-login the user like this (Only while running as a non root account): + + `http://yourserver:3000/wetty/autologin?sshuser=&sshpass=` + +This is just an additional feature and the security implications for passing the password in the url will have to be taken care separately. + +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: @@ -88,6 +112,8 @@ use: http://yourserver.com/wetty ``` +**Note that if your Nginx is configured for HTTPS you should run wetty without SSL.** + Else if you are running `bin/index.js` as a regular user you can use: ``` diff --git a/cli.mjs b/cli.mjs index c3e8ea3..f646992 100644 --- a/cli.mjs +++ b/cli.mjs @@ -25,6 +25,10 @@ const opts = optimist demand : false, description: 'ssh user', }, + sshpass: { + demand : false, + description: 'ssh password', + }, sshauth: { demand : false, description: 'defaults to "password", you can use "publickey,password" instead', @@ -52,6 +56,7 @@ if (opts.help) { } const sshuser = opts.sshuser || process.env.SSHUSER || ''; +const sshpass = opts.sshpass || process.env.SSHPASS || ''; const sshhost = opts.sshhost || process.env.SSHHOST || 'localhost'; const sshauth = opts.sshauth || process.env.SSHAUTH || 'password,keyboard-interactive'; const sshport = opts.sshport || process.env.SSHPORT || 22; @@ -81,7 +86,7 @@ process.on('uncaughtException', err => { console.error(`Error: ${err}`); }); -const tty = wetty(port, sshuser, sshhost, sshport, sshauth, sshkey, opts.ssl); +const tty = wetty(port, sshuser, sshpass, sshhost, sshport, sshauth, sshkey, opts.ssl); tty.on('exit', code => { console.log(`exit with code: ${code}`); }); diff --git a/docker-compose.yml b/docker-compose.yml index 310fd8f..3161613 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3" +version: "3.5" services: wetty: @@ -11,5 +11,16 @@ services: - "3000:3000" environment: PORT: 3000 - SSHHOST: 'localhost' + SSHHOST: 'wetty-ssh' SSHPORT: 22 + wetty-ssh: + build: + context: . + dockerfile: Dockerfile-ssh + container_name: 'wetty-ssh' + +networks: + default: + name: wetty + + diff --git a/public/wetty/index.html b/public/wetty/index.html index 1f468f9..3317d4b 100644 --- a/public/wetty/index.html +++ b/public/wetty/index.html @@ -3,7 +3,6 @@ Wetty - The WebTTY Terminal Emulator -