LoginSignup
0
0

More than 1 year has passed since last update.

[Ubuntu Server 22.04]  WeTTY インストール

Last updated at Posted at 2023-01-21

注意事項

リンク先に記載

[Ubuntu Server 22.04] 個人的初期設定 覚書

概要

「目次」

1.Tailscale インストール
2.WeTTY インストール
  概要
  コンストラクション
   前提
   WeTTY インストール手順
     1.インストレーション
      1.Node.js のインストール(NVM, Node.js, npm)
      2.WeTTY のインストール(yarn, WeTTY)
      3.起動
     2.https化
      1.(俺々)OpenSSL 証明書の作成
      2.SSH の鍵ファイルを作成
      3.起動
     3.WeTTY をPC起動時に自動起動させる
      1.systemd に user service として登録
      2.サービスを有効化 & WeTTY起動
  引用元、参照元、参考先
3.Ubuntu Desktop(GDM3 ubuntu カスタム) インストール、自動ログイン設定
4.Ubuntu Desktop RDP セットアップ
5.PowerTOP TLP インストール
6.自動再起動設定(Crontab, rtcwake)

「説明」

WeTTY は、ブラウザから TTY に接続できる SSH ターミナル ソフトウェアです。
WeTTY
NVM
NVM 更新一覧
更新 やり方
更新 やり方 サブ

コンストラクション

前提

bash
sudo apt update && sudo apt upgrade -y
sudo apt install -y vim openssh-server
ssh -V
sudo apt install -y build-essential curl python3

WeTTY インストール手順

1.インストレーション

1.Node.js のインストール(NVM, Node.js, npm)
bash
cd $HOME
# NVM を GitHub からインストール
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash && source ~/.profile
nvm install --lts
nvm install-latest-npm
node -v
2.WeTTY のインストール(yarn, WeTTY)
bash
mkdir -p ~/bin && source ~/.profile
npm install -g yarn --prefix ~/
yarn global add wetty --prefix ~/
wetty -h
3.起動
bash
ip -f inet -o addr show | grep -e eth -e wifi -e tail | awk -F '[: ]' '{print $1,$2,$3,$8}'

wetty --host 0.0.0.0 --port 4000 --title WeTTY --base /
# 終了 [Ctrl + C]

LAN内の他のPCなどのブラウザから上記IPアドレスのどれかにアクセス
URLの例: http://192.168.xxx.xxx:4000
ターミナルが表示されればOK

#バックグラウンドで実行したい場合
# バックグラウンドジョブ化
#   nohup wetty --host 0.0.0.0 --port 4000 --title WeTTY --base / >/dev/null 2>&1 &
# PID を一時ファイルに格納
#   echo $! > /tmp/wetty_http_PID
# 正常に実行されているかプロセスを確認
#   ps aux | xargs -a "/tmp/wetty_http_PID" grep
# 終了
#   xargs -a "/tmp/wetty_http_PID" kill

2.https化

1.(俺々)OpenSSL 証明書の作成

俺々じゃない証明書が欲しい場合は、Tailscale を使ってください。解説はしません。

bash
mkdir -p ~/.ssl
openssl req -x509 -nodes -days 1095 -newkey ec:<(openssl ecparam -name secp384r1) -subj "/C=GB/ST=None/L=None/O=None/OU=None/CN=None" -out ~/.ssl/wetty.crt -keyout ~/.ssl/wetty.key
chmod 700 ~/.ssl
chmod 644 ~/.ssl/wetty.crt
chmod 600 ~/.ssl/wetty.key
2.SSH の鍵ファイルを作成
bash
mkdir -p ~/.ssh
ssh-keygen -q -C "wetty-keyfile" -t ed25519 -N '' -f ~/.ssh/wetty 2>/dev/null <<< y >/dev/null
cat ~/.ssh/wetty.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 644 ~/.ssh/authorized_keys
chmod 600 ~/.ssh/wetty
3.起動
bash
ip -f inet -o addr show | grep -e eth -e wifi -e tail | awk -F '[: ]' '{print $1,$2,$3,$8}'

wetty --host 0.0.0.0 --port 5000 --title wetty --base / --ssh-key ~/.ssh/wetty --ssh-host localhost --ssh-user $(whoami) --ssh-port 22 --ssh-auth publickey --ssl-key ~/.ssl/wetty.key --ssl-cert ~/.ssl/wetty.crt
# 終了 [Ctrl + C]

LAN内の他のPCなどのブラウザから上記IPアドレスのどれかにアクセス
URLの例: https://192.168.xxx.xxx:5000
ターミナルが表示されればOK

3.WeTTY をPC起動時に自動起動させる

1.systemd に user service として登録
bash
mkdir -p ~/.config/systemd/user
vim ~/.config/systemd/user/wetty.service

# i を押す
# "##########"内を記述する
##########
[Unit]
Description=WeTTY
After=network-online.target

[Service]
Type=simple
ExecStart=/bin/bash -c "$$(source /home/$$(whoami)/.nvm/nvm.sh && nvm which current ) /home/$$(whoami)/bin/wetty --host 0.0.0.0 -p 5000 --title wetty --base / --ssh-key /home/$$(whoami)/.ssh/wetty --ssh-host localhost --ssh-user $$(whoami) --ssh-port 22 --ssh-auth publickey --ssl-key /home/$$(whoami)/.ssl/wetty.key --ssl-cert /home/$$(whoami)/.ssl/wetty.crt"
Restart=always
RestartSec=2
TimeoutStopSec=5
SyslogIdentifier=wetty

[Install]
WantedBy=default.target
##########
# Esc を押す
# :x を Enter
2.サービスを有効化 & WeTTY起動
bash
systemctl --user enable --now wetty
# 確認
systemctl --user status wetty

引用元、参照元、参考先

[WeTTY = Web + TTY] > AtoZ
 ・https://butlerx.github.io/wetty/#/atoz

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0