ヘッドレス運用が常の Raspberry Pi をネットワーク越しに操作する際に欠かせないssh、このsshが障害を起こしてログイン出来ない事態に見舞われ、人手での再起動を余儀なくされたことがありました。今後に備え、sshの代替管理手段として webmin を導入してみます。
きっかけとなった障害
きっかけとなったsshの障害は次の通りで、ハングしているのではなく、接続確立即断という振る舞いで、再試行しても同じでした。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
$ ssh -vvv USER@RASPBERRYPI OpenSSH_7.6p1 Ubuntu-4ubuntu0.4, OpenSSL 1.0.2n 7 Dec 2017 debug1: Reading configuration data /home/user/.ssh/config debug3: kex names ok: [diffie-hellman-group14-sha1] debug3: kex names ok: [curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256] debug3: kex names ok: [diffie-hellman-group14-sha1] debug3: kex names ok: [diffie-hellman-group1-sha1] debug3: kex names ok: [diffie-hellman-group1-sha1] debug3: kex names ok: [diffie-hellman-group1-sha1] debug3: kex names ok: [diffie-hellman-group1-sha1] debug3: kex names ok: [diffie-hellman-group1-sha1] debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: resolving "RASPBERRYPI" debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to RASPBERRYPI [###.###.###.###] debug1: Connection established. debug1: identity file /home/user/.ssh/id_rsa type 0 debug1: key_load_public: No such file or directory debug1: identity file /home/user/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/user/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/user/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/user/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/user/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/user/.ssh/id_ed25519-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.4 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1 Raspbian-5+deb8u8 debug1: match: OpenSSH_6.7p1 Raspbian-5+deb8u8 pat OpenSSH* compat 0x04000000 debug2: fd 3 setting O_NONBLOCK debug1: Authenticating to @RASPBERRYPI as 'USER' debug3: put_host_port: [RASPBERRYPI] debug3: hostkeys_foreach: reading file "/home/user/.ssh/known_hosts" debug3: send packet: type 20 debug1: SSH2_MSG_KEXINIT sent Connection closed by RASPBERRYPI |
このような時に何か別のインターフェースがあれば、と思いついたのがwebminでした。私の知るwebminはまだその黎明期の頃で、UIも機能も当時はかなり限定的でしたが、最近はRaspberry Piの普及も寄与してか、ユーザーも増えてきているようで気になっていました。
webminをインストール
Raspberry Piへのwebminのインストールは公式サイトからdebをダウンロードする方法がお手軽ですが、今回は公式レポジトリを追加してインストールしてみます。どちらの方法も公式サイトにその手順が示されているので、その通り進めるのみです。
具体的にはまず 「apt-get update」で最新状態とした後、「/etc/apt/source.list」に次の1行を追加し、
1 |
deb https://download.webmin.com/download/repository sarge contrib |
公開鍵をインポートします。
1 2 3 4 5 6 7 8 9 10 11 12 |
$ wget http://www.webmin.com/jcameron-key.asc --2020-08-07 13:55:54-- http://www.webmin.com/jcameron-key.asc Resolving www.webmin.com (www.webmin.com)... 216.105.38.10 Connecting to www.webmin.com (www.webmin.com)|216.105.38.10|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1320 (1.3K) [text/plain] Saving to: ‘jcameron-key.asc’ jcameron-key.asc 100%[===========================================>] 1.29K --.-KB/s in 0s 2020-08-07 13:55:54 (36.4 MB/s) - ‘jcameron-key.asc’ saved [1320/1320] $ sudo apt-key add jcameron-key.asc OK $ |
そしてaptをhttps通信に対応させるため「apt-transport-https」を入れてからアップデート、そしてwebminインストールの順に進めます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
$ sudo apt-get install apt-transport-https Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: apt-transport-https 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 134 kB of archives. After this operation, 185 kB of additional disk space will be used. WARNING: The following packages cannot be authenticated! apt-transport-https Install these packages without verification? [y/N] y Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main apt-transport-https armhf 1.0.9.8.6 [134 kB] Fetched 134 kB in 1s (118 kB/s) Selecting previously unselected package apt-transport-https. (Reading database ... 35986 files and directories currently installed.) Preparing to unpack .../apt-transport-https_1.0.9.8.6_armhf.deb ... Unpacking apt-transport-https (1.0.9.8.6) ... Setting up apt-transport-https (1.0.9.8.6) ... $ sudo apt-get update $ sudo apt-get install webmin Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: apt-show-versions libapt-pkg-perl libauthen-pam-perl libio-pty-perl libnet-ssleay-perl perl-openssl-defaults The following NEW packages will be installed: apt-show-versions libapt-pkg-perl libauthen-pam-perl libio-pty-perl libnet-ssleay-perl perl-openssl-defaults webmin 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded. Need to get 29.8 MB of archives. After this operation, 310 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://download.webmin.com/download/repository sarge/contrib armhf webmin all 1.954 [29.3 MB] Get:2 http://mirror.rise.ph/raspbian/raspbian buster/main armhf perl-openssl-defaults armhf 3 [6,782 B] Get:3 http://mirror.rise.ph/raspbian/raspbian buster/main armhf libnet-ssleay-perl armhf 1.85-2+b1 [286 kB] Get:4 http://mirror.rise.ph/raspbian/raspbian buster/main armhf libauthen-pam-perl armhf 0.16-3+b5 [25.9 kB] 13% [4 libauthen-pam-perl 0 B/25.9 kB 0%] [Connecting to raspbian.raspberrypi.org (93.93.128.193)] [1 webmin 2,388 kB/29.3 MB 8% Get:6 http://mirror.rise.ph/raspbian/raspbian buster/main armhf libapt-pkg-perl armhf 0.1.34+b1 [65.9 kB] Get:7 http://mirror.rise.ph/raspbian/raspbian buster/main armhf apt-show-versions all 0.22.11 [32.6 kB] Fetched 29.8 MB in 24s (1,232 kB/s) Selecting previously unselected package perl-openssl-defaults:armhf. (Reading database ... 39961 files and directories currently installed.) Preparing to unpack .../0-perl-openssl-defaults_3_armhf.deb ... Unpacking perl-openssl-defaults:armhf (3) ... Selecting previously unselected package libnet-ssleay-perl. Preparing to unpack .../1-libnet-ssleay-perl_1.85-2+b1_armhf.deb ... Unpacking libnet-ssleay-perl (1.85-2+b1) ... Selecting previously unselected package libauthen-pam-perl. Preparing to unpack .../2-libauthen-pam-perl_0.16-3+b5_armhf.deb ... Unpacking libauthen-pam-perl (0.16-3+b5) ... Selecting previously unselected package libio-pty-perl. Preparing to unpack .../3-libio-pty-perl_1%3a1.08-1.1+b4_armhf.deb ... Unpacking libio-pty-perl (1:1.08-1.1+b4) ... Selecting previously unselected package libapt-pkg-perl. Preparing to unpack .../4-libapt-pkg-perl_0.1.34+b1_armhf.deb ... Unpacking libapt-pkg-perl (0.1.34+b1) ... Selecting previously unselected package apt-show-versions. Preparing to unpack .../5-apt-show-versions_0.22.11_all.deb ... Unpacking apt-show-versions (0.22.11) ... Selecting previously unselected package webmin. Preparing to unpack .../6-webmin_1.954_all.deb ... Unpacking webmin (1.954) ... Setting up libapt-pkg-perl (0.1.34+b1) ... Setting up libio-pty-perl (1:1.08-1.1+b4) ... Setting up apt-show-versions (0.22.11) ... ** initializing cache. This may take a while ** Setting up perl-openssl-defaults:armhf (3) ... Setting up libauthen-pam-perl (0.16-3+b5) ... Setting up libnet-ssleay-perl (1.85-2+b1) ... Setting up webmin (1.954) ... /var/lib/dpkg/info/webmin.postinst: 4: /var/lib/dpkg/info/webmin.postinst: cannot create /etc/webmin/stop: Directory nonexistent Webmin install complete. You can now login to https://raspberrypi:10000/ as root with your root password, or as any user who can use sudo to run commands as root. Processing triggers for man-db (2.8.5-2) ... Processing triggers for systemd (241-7~deb10u4+rpi1) ... |
webminを試用
インストールを終えれば、もうwebminへはブラウザから次の要領でアクセスするだけ。ログイン画面では普段コンソール等で使っているIDでログインします。
1 |
https://IPADDRESS:10000/ |
今回障害発生したsshの項目、サービスの停止・開始をボタン一つで操作出来る他、一通りの設定がWebminから出来るようです。
左メニュー最下段に並ぶアイコンの中にターミナルのアイコンが有ります。押して見るとレイヤー被せてのターミナルウィンドウが開くのですが、TOPなど一部のコマンドは抑止されています。
これとは別にText Loginと言う機能が有り、こちらを使うと制限なくコンソール機能を使うことが出来ます。レスポンスもこちらの方が良い感じ。
またパッケージの更新があればページ上で通知してくれたりと、初心者のみならず忙しくてメンテをサボりがちな管理者にも有り難い限り。
とあちこちページを開いて探している機能は実は「シャットダウン・リブート」ボタンなのです。このBootup and Shutdownにあるようなのですが、そこに列記されているのはサービス。
長いページを一番下までスクロールしてやっとそのボタンを見付けました。そう安易に操作出来ないようにとの配慮かも知れませんが、そもそもこのページ、全サービスを列記するので他のページと比べ、ロードに時間が掛かってしまいます。
幸い、Reboot, Shutdown共にボタン押し後に確認ページが用意されているので、ここで☆ボタンをクリックしてお気に入りに登録すると、障害対応など非常時の再起動やシャットダウンに便利かもしれません(登録したお気に入りは左メニュー下段の★アイコンで呼び出せます)。
最後に何気なくRAIDのページを見てびっくり、ディスク4本中2本降格していました。もしかするとこれがそもそもの発端だったのかもしれません。と言うことで作業はこのRAIDの復旧に移りますが、それはまた別の記事へ。
失礼致します、Rastec会社の広報担当の胡と申します。BLOGにてお客様のレビューをご拝見させて頂きました、つきましてはお客様に弊社のラズベリーパイ4ケースレビューを投稿して頂きたく存じます。レビュー用機材に関しましては無償にて提供させて頂きます。御返事お待ちしております。どうぞよろしくお願いします。
商品レビューに関するご提案有難うございます。
ご登録頂きましたメールアドレス宛に返信させていただきましたが、そちらのメールサーバより
「550 Mail content denied」
とメール転送失敗メッセージを受け取りました。
有効なメールアドレスをお知らせください。