Webブラウザでターミナル入力ができるbutterflyというソフトウェアがあることを知りました。Webブラウザ内でターミナルが動く、という点で似たようなことができそうなソフトウェアとしては、shellinaabox、webssh、sshwifty、ttyd、wettyなどもありそうですが、まずはbutterflyを試してみます。(ttydはOpenWRTでも動くようです)
インストール
以下の手順でインストールします。
~/python$ cd python3 ~/python$ python3 -m venv butterfly ~/python$ cd butterfly/ ~/python/butterfly$ source bin/activate (butterfly) ~/python/butterfly$ pip install --upgrade pip (butterfly) ~/python/butterfly$ pip install butterfly Collecting butterfly Downloading butterfly-3.2.5-py2.py3-none-any.whl (1.1 MB) Collecting pyOpenSSL Downloading pyOpenSSL-20.0.0-py2.py3-none-any.whl (54 kB) Collecting cryptography>=3.2 Downloading cryptography-3.3.1-cp36-abi3-manylinux2010_x86_64.whl (2.6 MB) Collecting cffi>=1.12 Downloading cffi-1.14.4-cp38-cp38-manylinux1_x86_64.whl (411 kB) Collecting pycparser Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB) Collecting six>=1.5.2 Downloading six-1.15.0-py2.py3-none-any.whl (10 kB) Collecting tornado>=3.2 Downloading tornado-6.1-cp38-cp38-manylinux2010_x86_64.whl (427 kB) (butterfly) ~/python/butterfly$
証明書の生成とインストール
サーバ証明書(たぶん)を作ります。
(butterfly) ~/python/butterfly$ butterfly.server.py --generate-certs --host=localhost butterfly.conf installed in /home/ユーザー名/.config/butterfly/butterfly.conf Generating certificates for localhost (change it with --host) Root certificate not found, generating it Writing /home/ユーザー名/.config/butterfly/ssl/butterfly_ca.crt Writing /home/ユーザー名/.config/butterfly/ssl/butterfly_ca.key Writing /home/ユーザー名/.config/butterfly/ssl/butterfly_localhost.crt Writing /home/ユーザー名/.config/butterfly/ssl/butterfly_localhost.key Now you can run --generate-user-pkcs=user to generate user certificate.
ユーザー証明書を作ります。
(butterfly) ~/python/butterfly$ butterfly.server.py --generate-user-pkcs=$USER Reading /home/ユーザー名/.config/butterfly/ssl/butterfly_ca.crt Reading /home/ユーザー名/.config/butterfly/ssl/butterfly_ca.key PKCS12 Password (can be blank): Verify Password (can be blank): Writing /home/ユーザー名/.config/butterfly/ssl/ユーザー名.p12
生成した拡張子p12のユーザー証明書をGoogle Chromeのプライバシーとセキュリティの証明書の管理でインポートします。
起動して確認
オプション等を付けずに起動して、サーバーを起動します。
(butterfly) ~/python/butterfly$ butterfly.server.py /home/ユーザー名/python/butterfly/bin/butterfly.server.py:384: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead log.warn('Butterfly is ready, open your browser to: %s' % url)
https://localhost:57575/ にアクセスすると、証明書の選択を経て実際にシェルが起動できました。(localhostの場合は証明書が適切ではない、ということになってしまうようです)

実際に触ってみるとレスポンスも良好なようです。どんな使い方があるか調べていきたいと思います。