Gateone

From ArchWiki
Revision as of 12:45, 29 January 2014 by Snis (Talk | contribs)

Jump to: navigation, search

From Gate One ✈ Web Terminal Emulator and SSH Client:

Gate One™ is a web-based Terminal Emulator and SSH client that brings the power of the command line to the web. It requires no browser plugins and is built on top of a powerful plugin system that allows every aspect of its appearance and functionality to be customized.

Gate One enables users to access SSH servers over the web. alternatives exist, such as Guacamole. One of Gate One's distinguishing features is the ability to resume sessions from other browsers or to replay sessions.

This guide covers Gate One setup behind nginx as reverse proxy.

Installation

Gate One is written in Python and use Tornado as a web framework. Gate One uses WebSockets for communication.

Prerequisites

Gate One requires Python 2.6+ or 3.2+, however the AUR build depends on python2. More information can be found at http://liftoff.github.io/GateOne/About/index.html#prerequisites

python2
Gate One is written in Python.
python2-futures
Back port of concurrent.futures in Python3, provides interface for asynchronously executing callables.
python2-setuptools
Easily download, build, install and upgrade Python packages.
python2-tornado
Tornado is a Python web framework, ideal for long polling WebSockets.

Optional Prerequisites

If you want to be able to upgrade (restart) Gate One without losing user's connected sessions you have to have dtach installed. This option is enabled by default in the configuration.

dtach
emulates the detach feature of screen

Installing Packages

gateone-gitAUR

First install the package available from the AUR

yaourt -S gateone-git

Optional: install dtach:

sudo pacman -S dtach

Managing the gateone daemon

You can start gateone with the following command:

# systemctl start gateone

You can enable gateone at startup with the following command:

# systemctl enable gateone 
Warning: By default gateone allows anonymous users to access the service. Please make sure to change the settings.

Configuration

Let’s edit the configuration to suite your needs. There are three configuration files by default. located under /etc/gateone/conf.d/

All options are described at: http://liftoff.github.io/GateOne/About/index.html#configuration

Keep in mind that these options are split up in three configuration files. I will go through only some of them.

Main settings

The main server settings are found in 10server.conf.

cd /etc/gateone/conf.d
sudo vi 10server.conf

"address": "" This tells Gate One to listen on all addresses. "address": "localhost;::1;10.1.1.100" Gate One will listen on localhost (IPv4 and IPv6) and on 10.1.1.100.

"disable_ssl": false or true, if you are handling SSL offloading somewhere else.

"origins": ["localhost", "127.0.0.1", "serverhostname", "10.1.1.100", "full.domain.name", Add all URL's that will be used when connecting to Gate One. Failed attempts will be logged, look for "unknown origins" with systemctl status gateone

"port": 443 What TCP port Gate One will listen on.

"url_prefix": "/" Specifies the URL path, if set to "/gateone/" the address will be https://10.1.1.100/gateone/

Authentication settings

The authentication settings are found in 20authentication.conf.

cd /etc/gateone/conf.d
sudo vi 20authentication.conf

"auth": "none" Can be "none", "pam", google", "kerberos" or "api".

None

None is no authentication and allows anonymous access. Sessions will be tied to browser cookie.

PAM

PAM authentication can be used to authenticate with local users, but PAM can do much more. For example, you can authenticate against htpasswd files. Requires pam_pwdfileAUR. Gate One uses Crypt encryption so use switch -d. "auth": "pam" "pam_service": "gateonepwd":

htpasswd -c -d /etc/gateone/users.passwd user1
vi /etc/pam.d/gateonepwd
#%PAM-1.0
# Login using a htpasswd file
@include common-sessionauth    
required pam_pwdfile.so          pwdfile /etc/gateone/users.passwd
required pam_permit.so

Google

Google Authentication uses Google to authenticate (Gmail or Google+).

All authenticated modes enable you to resume your sessions on a different browser.

Terminal settings

Here you can add terminals and options for them. I'm using it to control what are accessible to my Google authenticated user. For more information look here: https://github.com/liftoff/GateOne/blob/master/gateone/applications/terminal/docs/configuration.rst

cd /etc/gateone/conf.d
sudo vi 20authentication.conf

Example to only allow example@gmail.com and test@gmail.com to access the SSH application:

20authentication.conf
 // This is Gate One's Terminal application settings file.
{
    // "*" means "apply to all users" or "default"
    "*": {
       "terminal": { // These settings apply to the "terminal" application
            "commands": {
                "SSH": {"command": "/usr/lib/python2.7/site-packages/gateone/applications/terminal/plugins/ssh/scripts/ssh_connect.py -S '%SESSION_DIR%/%SESSION%/%SHORT_SOCKET%' --sshfp -a '-oUserKnownHostsFile=\\\"%USERDIR%/%USER%/
.ssh/known_hosts\\\"'", "description": "Connect to hosts via SSH."}
            },
            "default_command": "SSH",
            "dtach": true,
            "environment_vars": {"TERM": "xterm-256color"},
            "session_logging": true,
            "syslog_session_logging": false,
            "allow": false
        }
    },
    // "*" means "apply to all users" or "default"
    "user.upn=(example@gmail.com|test@gmail.com)": {
       "terminal": { // These settings apply to the "terminal" application
            "commands": {
                "SSH": {"command": "/usr/lib/python2.7/site-packages/gateone/applications/terminal/plugins/ssh/scripts/ssh_connect.py -S '%SESSION_DIR%/%SESSION%/%SHORT_SOCKET%' --sshfp -a '-oUserKnownHostsFile=\\\"%USERDIR%/%USER%/
.ssh/known_hosts\\\"'", "description": "Connect to hosts via SSH."}
            },
            "default_command": "SSH",
            "dtach": true,
            "environment_vars": {"TERM": "xterm-256color"},
            "session_logging": true,
            "syslog_session_logging": false,
            "allow": true
        }
    }
 }

Proxied

Using a reverse proxy to handle SSL and more than just Gate One on the same IP-address:443 listener is possible, but please note that Gate One uses WebSocket and that the reverse proxy must be able to handle WebSockets.

Nginx

I use nginx so here is a quick walkthrough. I like this method because it is quick and easy. Make sure that the port that the Gate One server is running on is blocked from outside by a proxy (like iptables) or if you are running Gate One and nginx on the same server make sure it only listens on localhost. Please see Nginx for more information about installing.

Edit your nginx configuration file similar to this:

Note: Listed below are only the server part of the nginx configuration
sudo vi /etc/nginx/nginx.conf

nginx.conf
# HTTPS server
server {
	listen       [::]:443;
	listen       443;
	server_name  mysslhost;

	ssl                  on;
	ssl_certificate      server.crt;
	ssl_certificate_key  server.key;
	ssl_session_timeout  5m;
	ssl_protocols  SSLv2 SSLv3 TLSv1;
	ssl_ciphers  HIGH:!aNULL:!MD5;
	ssl_prefer_server_ciphers   on;

    location /gateone/ {
		#auth_basic "Restricted";					#One extra layer of authentication
		#auth_basic_user_file /etc/nginx/.htpasswd;
		proxy_pass_header Server;
		proxy_set_header Host $http_host;
		proxy_redirect off;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Scheme $scheme;
		proxy_pass http://localhost:8888;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
	}
	location /other {
		rewrite /other/(.*) /$1 break;
		include /etc/nginx/proxy.conf;
		proxy_pass http://10.1.1.200:80;
		break;
	}
}
Note: The above configuration requires the following Gate One configuration
10server.conf
	"disable_ssl": true,
	"https_redirect": false,
	"port": 8888,
	"url_prefix": "/gateone/"

Gate One now lives under the URL: https://your-nginx-server:443/gateone/