[Ubuntu 22.04] SoftEther VPN サーバーをアンインストールする方法
前書き
さくらの VPS 上のサーバー (Ubuntu 22.04) にインストールしていた SoftEther VPN サーバー (以降 VPN サーバー) を使わなくなったのでアンインストールすることにした。
アンインストールに当たっては公式サイトの情報を参照した。
アンインストール手順
現状確認
VPN サーバープロセスを確認する。
$ ps -ef | grep vpn root 576 1 0 May26 ? 00:00:00 /usr/local/vpnserver/vpnserver execsvc root 577 576 1 May26 ? 01:58:00 /usr/local/vpnserver/vpnserver execsvc hoge 203222 203085 0 14:52 pts/0 00:00:00 grep vpn $ ls -l /usr/local/vpnserver total 16272 -rw------- 1 root root 82 Apr 26 2022 Authors.txt -rw------- 1 root root 3577 Apr 26 2022 Makefile -rw------- 1 root root 32256 Apr 26 2022 ReadMeFirst_Important_Notices_cn.txt -rw------- 1 root root 37747 Apr 26 2022 ReadMeFirst_Important_Notices_en.txt -rw------- 1 root root 52554 Apr 26 2022 ReadMeFirst_Important_Notices_ja.txt -rw------- 1 root root 3587 Apr 26 2022 ReadMeFirst_License.txt drwx------ 2 root root 4096 Jun 3 14:00 backup.vpn_server.config drw------- 2 root root 4096 Jun 11 2022 chain_certs drw------- 2 root root 4096 Jun 11 2022 code -rw------- 1 root root 2009248 Apr 26 2022 hamcore.se2 -rw------- 1 root root 867 Jun 11 2022 lang.config drw------- 2 root root 4096 Jun 11 2022 lib drwx------ 4 root root 4096 Jul 9 2022 packet_log drwx------ 5 root root 4096 Jul 9 2022 security_log drwx------ 2 root root 20480 Jun 3 00:41 server_log -rw------- 1 root root 27345 Jun 3 14:50 vpn_server.config -rwx------ 1 root root 7214120 Jun 11 2022 vpncmd -rwx------ 1 root root 7214192 Jun 11 2022 vpnserver $
-> 起動していることが確認できる。VPN サーバーの各ファイルは /usr/local/vpnserver ディレクトリにある。
VPN サーバーは systemd で管理しているが、VPN サーバーのサービスの状態を確認する。
$ sudo systemctl status softether ● softether.service - SoftEther VPN Server Loaded: loaded (/etc/systemd/system/softether.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2023-05-26 15:40:10 JST; 1 weeks 0 days ago Process: 525 ExecStart=/usr/local/vpnserver/vpnserver start (code=exited, status=0/SUCCESS) Main PID: 576 (vpnserver) Tasks: 60 (limit: 629145) Memory: 6.2M CGroup: /system.slice/softether.service ├─576 /usr/local/vpnserver/vpnserver execsvc └─577 /usr/local/vpnserver/vpnserver execsvc May 26 15:40:04 os4-437-63610 systemd[1]: Starting SoftEther VPN Server... May 26 15:40:05 os4-437-63610 vpnserver[525]: The SoftEther VPN Server service has been started. May 26 15:40:07 os4-437-63610 vpnserver[525]: Let's get started by accessing to the following URL from your PC: May 26 15:40:07 os4-437-63610 vpnserver[525]: https://xx.xx.xx.xx:5555/ May 26 15:40:07 os4-437-63610 vpnserver[525]: or May 26 15:40:07 os4-437-63610 vpnserver[525]: https://xx.xx.xx.xx/ May 26 15:40:07 os4-437-63610 vpnserver[525]: Note: IP address may vary. Specify your server's IP address. May 26 15:40:07 os4-437-63610 vpnserver[525]: A TLS certificate warning will appear because the server uses self signed certificate by default. That is natural. Continue w> May 26 15:40:10 os4-437-63610 systemd[1]: Started SoftEther VPN Server. $ ls -l /etc/systemd/system/softether* -rw-r--r-- 1 root root 215 Jun 11 2022 /etc/systemd/system/softether.service $
-> active であることがわかる。
-> systemd で使っている VPN サーバーの設定ファイル (ユニットファイル) が /etc/systemd/system/softether.service であることがわかる。
VPN サーバーのサービスを止める
sudo systemctl stop softetherコマンドで VPN Server のサービスを停止させます。このコマンドを実行すると以下のことが起こります。
SoftEther サービスが現在実行中であれば、プロセスが停止します。これにより、サービスが提供していた機能や機能の処理が終了します。サービスの状態が「停止」(inactive) に変更されます。これはsystemctl status softether コマンドで確認できます。(出典: ChatGPT)
実際にやってみます。
$ sudo systemctl stop softether $ sudo systemctl status softether ● softether.service - SoftEther VPN Server Loaded: loaded (/etc/systemd/system/softether.service; enabled; vendor preset: enabled) Active: inactive (dead) since Sat 2023-06-03 15:04:12 JST; 18s ago Process: 525 ExecStart=/usr/local/vpnserver/vpnserver start (code=exited, status=0/SUCCESS) Process: 203363 ExecStop=/usr/local/vpnserver/vpnserver stop (code=exited, status=0/SUCCESS) Main PID: 576 (code=exited, status=0/SUCCESS) May 26 15:40:07 os4-437-63610 vpnserver[525]: or May 26 15:40:07 os4-437-63610 vpnserver[525]: https://xx.xx.xx.xx/ May 26 15:40:07 os4-437-63610 vpnserver[525]: Note: IP address may vary. Specify your server's IP address. May 26 15:40:07 os4-437-63610 vpnserver[525]: A TLS certificate warning will appear because the server uses self signed certificate by default. That is natural. Continue w> May 26 15:40:10 os4-437-63610 systemd[1]: Started SoftEther VPN Server. Jun 03 15:03:50 os4-437-63610 systemd[1]: Stopping SoftEther VPN Server... Jun 03 15:03:50 os4-437-63610 vpnserver[203363]: Stopping the SoftEther VPN Server service ... Jun 03 15:04:10 os4-437-63610 vpnserver[203363]: SoftEther VPN Server service has been stopped. Jun 03 15:04:12 os4-437-63610 systemd[1]: softether.service: Succeeded. Jun 03 15:04:12 os4-437-63610 systemd[1]: Stopped SoftEther VPN Server. $ ps -ef | grep vpn hoge 203407 203085 0 15:04 pts/0 00:00:00 grep vpn $
-> ChatGPT に教えてもらったように inactive になりましたね。
-> VPN サーバーのプロセスもなくなっています。
サービスが自動起動しないように disable にします。
$ sudo systemctl disable softether Removed /etc/systemd/system/multi-user.target.wants/softether.service. $ sudo systemctl status softether ● softether.service - SoftEther VPN Server Loaded: loaded (/etc/systemd/system/softether.service; disabled; vendor preset: enabled) Active: inactive (dead) May 26 15:40:07 os4-437-63610 vpnserver[525]: or May 26 15:40:07 os4-437-63610 vpnserver[525]: https://xx.xx.xx.xx/ May 26 15:40:07 os4-437-63610 vpnserver[525]: Note: IP address may vary. Specify your server's IP address. May 26 15:40:07 os4-437-63610 vpnserver[525]: A TLS certificate warning will appear because the server uses self signed certificate by default. That is natural. Continue w> May 26 15:40:10 os4-437-63610 systemd[1]: Started SoftEther VPN Server. Jun 03 15:03:50 os4-437-63610 systemd[1]: Stopping SoftEther VPN Server... Jun 03 15:03:50 os4-437-63610 vpnserver[203363]: Stopping the SoftEther VPN Server service ... Jun 03 15:04:10 os4-437-63610 vpnserver[203363]: SoftEther VPN Server service has been stopped. Jun 03 15:04:12 os4-437-63610 systemd[1]: softether.service: Succeeded. Jun 03 15:04:12 os4-437-63610 systemd[1]: Stopped SoftEther VPN Server. $
-> ユニットファイル (/etc/systemd/system/softether.service) が disabled に変わりました。
マストではないと思いますけど、ここで shutdown -r now で再起動しました。再起動したあとに、VPN サーバーがサービスとして起動しなくなることを念押しで確認しようと思ったので。
要らなくなったファイルの削除
再起動後の確認です。
$ ps -ef | grep vpn hoge 944 708 0 15:11 pts/0 00:00:00 grep vpn $ sudo systemctl status softether Unit softether.service could not be found. $
-> プロセスがないこと = サービスとして起動していないことを確認した。
あとは、VPN サーバー関連ファイルを削除します。
$ ls -ld /usr/local/vpnserver/ drwxrwxr-x 8 hoge hoge 4096 Jun 3 15:12 /usr/local/vpnserver/ $ sudo rm -rf !$ sudo rm -rf /usr/local/vpnserver/ $
ユニットファイルも不要なので削除しておしまいです。
$ sudo rm /etc/systemd/system/softether.service $ ls -l !$ ls -l /etc/systemd/system/softether.service ls: cannot access '/etc/systemd/system/softether.service': No such file or directory $