Gateone
Gate One ✈ Web Terminal Emulator and SSH Client より:
- Gate One™ はコマンドラインの力をウェブにもたらすウェブベースのターミナルエミュレータであり SSH クライアントです。ブラウザプラグインは必要とせず、強力なプラグインシステムによって外観・機能をカスタマイズすることができます。
Gate One を使うことでウェブから SSH サーバーにアクセスすることができおます。似たようなソフトウェアとして Guacamole が存在します。Gate One の特徴として他のブラウザからセッションを復帰したりセッションを再生することが可能です。
このガイドでは nginx をリバースプロキシとして使用して Gate One をセットアップする方法を説明します。
目次
インストール
Gate One は AUR から gateone-gitAUR パッケージでインストールできます。
任意の依存パッケージ
ユーザーのセッション接続を保ったまま Gate One をアップグレード (再起動) したい場合、dtach をインストールしてください。デフォルトで設定オプションが有効になっています。
設定
インストールが完了したら gateone を起動して自己署名 ssl 証明書とデフォルト設定を生成します:
# gateone
そして設定を自由に編集してください。デフォルトでは /etc/gateone/conf.d/ に3つの設定ファイルが存在します。
全てのオプションは http://liftoff.github.io/GateOne/About/index.html#configuration で解説されています。
メイン設定
メインのサーバー設定は /etc/gateone/conf.d/10server.conf にあります。
/etc/gateone/conf.d/10server.conf
{
// "gateone" server-wide settings fall under "*"
"*": {
"gateone": { // These settings apply to all of Gate One
"address": "",
"ca_certs": null,
"cache_dir": "/tmp/gateone_cache",
"certificate": "/etc/gateone/ssl/certificate.pem",
"combine_css": "",
"combine_css_container": "gateone",
"combine_js": "",
"cookie_secret": "ZTRiOGUzNjM5ZmNjNDJjODllNDRmODk3Y2RjZTVlNTc4M",
"debug": false,
"disable_ssl": false,
"embedded": false,
"enable_unix_socket": false,
"gid": "0",
"https_redirect": false,
"js_init": "",
"keyfile": "/etc/gateone/ssl/keyfile.pem",
"locale": "en_US",
"log_file_max_size": 100000000,
"log_file_num_backups": 10,
"log_file_prefix": "/var/log/gateone/gateone.log",
"log_to_stderr": null,
"logging": "info",
"origins": ["localhost", "127.0.0.1", "10.1.1.100"],
"pid_file": "/var/run/gateone.pid",
"port": 443,
"session_dir": "/tmp/gateone",
"session_timeout": "5d",
"syslog_facility": "daemon",
"syslog_host": null,
"uid": "0",
"unix_socket_path": "/tmp/gateone.sock",
"url_prefix": "/",
"user_dir": "/var/lib/gateone/users",
"user_logs_max_age": "30d"
}
}
}
"address": ""は Gate One で使用するアドレスを指定します。例えば"address": "localhost;::1;10.1.1.100"とした場合 Gate One は localhost (IPv4 と IPv6) と 10.1.1.100 を listen します。
- SSL のオフロードを別のところで処理する場合
"disable_ssl": falseを true にしてください。
"origins": ["localhost", "127.0.0.1", "serverhostname", "10.1.1.100", "full.domain.name",には Gate One に接続するときに使用する URL を追加します。
"port": 443は Gate One が使用する TCP ポートです。
"url_prefix": "/"には URL のパスを設定します。"/gateone/" と設定した場合、アドレスは https://10.1.1.100/gateone/ になります。
認証設定
認証設定は /etc/gateone/conf.d/20authentication.conf にあります。
/etc/gateone/conf.d/20authentication.conf
// This is Gate One's authentication settings file.
{
// "gateone" server-wide settings fall under "*"
"*": {
"gateone": { // These settings apply to all of Gate One
"api_timestamp_window": "30s",
"auth": "none",
"pam_realm": "hostname",
"pam_service": "login",
"ssl_auth": "none",
"sso_keytab": null,
"sso_realm": null,
"sso_service": "HTTP"
}
}
}
"auth": "none"には "none", "pam", google", "kerberos", "api" のどれかを指定できます。
None
None は認証を行いません。匿名アクセスが許可されます。セッションはブラウザの cookie と紐付けられます。
PAM
PAM 認証を使うことでローカルユーザーで認証することができます。さらに htpasswd ファイルで認証することなども可能です。libpam_pwdfileAUR が必要です。
/etc/gateone/conf.d/20authentication.conf
"auth": "pam" "pam_service": "gateonepwd"
Gate One は Crypt 暗号化を使用するため -d スイッチを使ってください:
# htpasswd -c -d /etc/gateone/users.passwd user1
PAM サービスファイルを作成してください。空白は全て <TAB> なので注意してください。
/etc/pam.d/gateonepwd
#%PAM-1.0 # Login using a htpasswd file #@include common-sessionauth auth required pam_pwdfile.so pwdfile /etc/gateone/users.passwd account required pam_permit.so
Google Authentication は Google で認証を行います (Gmail または Google+)。
ターミナル設定
ターミナルとオプションを追加することができます。詳しくは https://github.com/liftoff/GateOne/blob/master/gateone/applications/terminal/docs/configuration.rst を見てください。
example@gmail.com と test@gmail.com で SSH アプリケーションへのアクセスを許可する例:
/etc/gateone/conf.d/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
}
}
}
リバースプロキシ
リバースプロキシを使って SSL を処理したり同一の IP アドレスで Gate One 以外を使うことができるようになります。ただし Gate One は WebSocket を使用するためリバースプロキシが WebSocket に対応している必要があります。
Nginx
Gate One サーバーが使用するポートを (iptables など) ファイアウォールによって塞ぐか、あるいは Gate One と nginx を同一サーバー上で動かす場合、ローカルホストだけを listen するようにしてください。詳しくは Nginx を参照。
nginx の設定ファイルを以下のように編集してください:
/etc/nginx/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_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;
}
}
/etc/gateone/conf.d/10server.conf
"disable_ssl": true, "https_redirect": false, "port": 8888, "url_prefix": "/gateone/"
Gate One には https://your-nginx-server:443/gateone/ からアクセスできます。
Systemd の統合
Gate One パッケージには systemd のサービスファイルが付属しています: gateone.service。
トラブルシューティング
Gate One でターミナルを開けないという問題が報告されています。原因は Gate One が python を実行しようとするためです。Python#Python 2 を参照してください。