さくらの VPS にある Ubuntu に SoftEther VPN クライアントをコマンド操作でインストールする

背景

我が家にはパナソニックのレッツノート CF-S10 にインストールした Ubuntu のデスクトップ版がある。デスクトップ版 Ubuntu ではあるが、実質的にサーバーとして使っている部分もそこそこあり、この Ubuntu のバックアップについて考える必要性を感じはじめている。

バックアップといってもたいしたことではなく、僕が勉強がてらに書いている Python のスクリプトをバックアップしたいというレベルだ。で、そのバックアップ先に さくらの VPS にある Ubuntu を使おうというわけだ。

自宅 Ubuntu のデータをバックアップするための方法としては rsync かなにかでコピーしようかと思っている。そのための土台として 自宅 Ubuntu とさくら VPS Ubuntu を SoftEther VPN でセキュアにつなごうと思っている。

すでに自宅 Ubuntu は SoftEther VPN サーバーとして稼働している状態だ。だから本投稿では、さくら VPS の Ubuntu に SoftEther VPN クライアント (以下 VPN クライアントと略すことあり) をインストールしていく。

インストールにあたっては CLI 操作、コマンドだけで実行していくつもりだ。

参考記事:[Raspberry Pi] SoftEther VPN クライアントをインストールする方法

前提

さくらの VPS にある Ubuntu は既にセットアップ済みで ssh ログインができる状態。これを前提として以下に寄稿していく。

作業は僕のメインパソコンである MacBook Pro で行う。MacBook Pro からさくら VPS の Ubuntu に ssh ログインしてインストールをしていく。

また、GUI 操作で設定が可能になるソフト = SoftEther VPN Server Manager は一切使いません。

SoftEther VPN クライアントのダウンロード

まず MacBook Pro で SoftEther のダウンロードセンターにアクセスする。そこから SoftEther VPN の Linux 版で 64 bit 版を選択する。

そうすると、ダウンロード可能な SoftEther VPN クライアント のリストが表示されるだろう。今回は一番上に表示された Ver 4.34, Build 9745 をダウンロードする。が、ここでやるべきことは、MacBook Pro で Build 9745 をダウンロードするリンクの URL をコピーすることだ。

コピーしたら MacBook Pro から、さくら VPS Ubuntu に ssh ログインする。

ssh ログインしたら、wget コマンドに –spider オプションを付けてコピーした URL を確認する。

$ wget https://jp.softether-download.com/files/softether/v4.34-9745-rtm-2020.04.05-tree/Linux/SoftEther_VPN_Client/64bit_-Intel_x64_or_AMD64/softether-vpnclient-v4.34-9745-rtm-2020.04.05-linux-x64-64bit.tar.gz --spider
Spider mode enabled. Check if remote file exists.
--2021-01-16 17:50:17--  https://jp.softether-download.com/files/softether/v4.34-9745-rtm-2020.04.05-tree/Linux/SoftEther_VPN_Client/64bit-_Intel_x64_or_AMD64/softether-vpnclient-v4.34-9745-rtm-2020.04.05-linux-x64-64bit.tar.gz
Resolving jp.softether-download.com (jp.softether-download.com)… 130.158.75.49
Connecting to jp.softether-download.com (jp.softether-download.com)|130.158.75.49|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 7510242 (7.2M) [application/x-gzip]
Remote file exists.

$

上記のように Remote file exists. と表示されればそこにファイル (SoftEther VPN クライアント) があるということだ。–spider オプションを付けないで wget を実行しよう。

$ wget https://jp.softether-download.com/files/softether/v4.34-9745-rtm-2020.04.05-tree/Linux/SoftEther_VPN_Client/64bit_-Intel_x64_or_AMD64/softether-vpnclient-v4.34-9745-rtm-2020.04.05-linux-x64-64bit.tar.gz
--2021-01-16 17:52:53--  https://jp.softether-download.com/files/softether/v4.34-9745-rtm-2020.04.05-tree/Linux/SoftEther_VPN_Client/64bit-_Intel_x64_or_AMD64/softether-vpnclient-v4.34-9745-rtm-2020.04.05-linux-x64-64bit.tar.gz
Resolving jp.softether-download.com (jp.softether-download.com)… 130.158.75.49
Connecting to jp.softether-download.com (jp.softether-download.com)|130.158.75.49|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 7510242 (7.2M) [application/x-gzip]
Saving to: ‘softether-vpnclient-v4.34-9745-rtm-2020.04.05-linux-x64-64bit.tar.gz’

softether-vpnclient-v4 100%[============================>]   7.16M  4.21MB/s    in 1.7s

2021-01-16 17:52:55 (4.21 MB/s) - ‘softether-vpnclient-v4.34-9745-rtm-2020.04.05-linux-x64-64bit.tar.gz’ saved [7510242/7510242]

$ ls -l softether*
 -rw-rw-r-- 1 nobi nobi 7510242 Apr  5  2020 softether-vpnclient-v4.34-9745-rtm-2020.04.05-linux-x64-64bit.tar.gz
$

これでダウンロードができた。

ちなみにダウンロードする場所 (ディレクトリ) はどこでも良い。なぜかというと、インストールが終わってしまえば SoftEther VPN クライアントは /usr/local に配置される (する) し、ダウンロードしてきたこの .tar.gz ファイルは削除するからだ。

もし、こだわりをお持ちならその場所にダウンロードして、この先のインストール作業をすれば良い。

SoftEther VPN クライアントのインストール

解凍・展開して sudo make と叩くだけである。

$ tar -zxvf softether-vpnclient-v4.34-9745-rtm-2020.04.05-linux-x64-64bit.tar.gz
vpnclient/
vpnclient/Makefile
vpnclient/.install.sh
vpnclient/ReadMeFirst_License.txt
vpnclient/Authors.txt
vpnclient/ReadMeFirst_Important_Notices_ja.txt
vpnclient/ReadMeFirst_Important_Notices_en.txt
vpnclient/ReadMeFirst_Important_Notices_cn.txt
vpnclient/code/
vpnclient/code/vpnclient.a
vpnclient/code/vpncmd.a
vpnclient/lib/
vpnclient/lib/libcharset.a
vpnclient/lib/libcrypto.a
vpnclient/lib/libedit.a
vpnclient/lib/libiconv.a
vpnclient/lib/libintelaes.a
vpnclient/lib/libncurses.a
vpnclient/lib/libssl.a
vpnclient/lib/libz.a
vpnclient/lib/License.txt
vpnclient/hamcore.se2
$ cd vpnclient/
$ sudo make

もし make がないと怒られたら、make コマンド (以下 make) がインストールされていない可能性がある。その場合は sudo apt-get install make などと叩いて make をインストールしよう。

また make がインストールされていないなら gcc コマンド (以下 gcc) もインストールされていないかもしれない。gcc がないと、sudo make と叩いても SoftEther VPN クライアントのインストールはできない。だから gcc がない場合は gcc もインストールしよう。sudo apt-get install gcc とか叩けばインストールできるだろう。

とにかくポイントとしては make も gcc もインストールされた状態で sudo make と叩く必要があるということだ。

make と gcc がインストールされているかどうかわからないなら which make とか which gcc と叩いてみよう。なんの表示も返ってこなかったらインストールされていないと考えてほぼほぼ間違いないだろう。

参考までに僕のさくら VPS の Ubuntu では以下の make と gcc をインストール済みだ。

$ make --version
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$

話が脱線したかもしれないが、SoftEther VPN クライアントをインストールするための sudo make に話を戻そう。sudo make と叩いた後、いくつか質問されるが、そこは 1 とか yes の回答をしてインストールを進めていくことになる。

VPN クライアントを /usr/local へ配置するのとパーミッション変更

無事 sudo make が終わったら VPN クライアントを /usr/local に移動させてファイルのパーミッション変更を行う。

$ cd ..
$ rm softether-vpnclient-v4.34-9745-rtm-2020.04.05-linux-x64-64bit.tar.gz
$ sudo mv vpnclient/ /usr/local
$ cd /usr/local/vpnclient/
$ sudo chmod 600 *
$ sudo chmod 700 vpncmd
$ sudo chmod 700 vpnclient
$ sudo chown root:root *
$ ls -l
total 13256
-rw------- 1 root root      82 Apr  5  2020 Authors.txt
-rw------- 1 root root    3584 Apr  5  2020 Makefile
-rw------- 1 root root   32075 Apr  5  2020 ReadMeFirst_Important_Notices_cn.txt
-rw------- 1 root root   37566 Apr  5  2020 ReadMeFirst_Important_Notices_en.txt
-rw------- 1 root root   52340 Apr  5  2020 ReadMeFirst_Important_Notices_ja.txt
-rw------- 1 root root    3587 Apr  5  2020 ReadMeFirst_License.txt
drw------- 2 root root    4096 Jan 16 18:14 code
-rw------- 1 root root 2008977 Apr  5  2020 hamcore.se2
drw------- 2 root root    4096 Jan 16 18:14 lib
-rwx------ 1 root root 5704632 Jan 16 18:14 vpnclient
-rwx------ 1 root root 5708648 Jan 16 18:14 vpncmd
$ pwd
/usr/local/vpnclient
$

以上で SoftEther VPN クライアントのインストール作業は終了である。

SoftEther VPN クライアントの起動と終了

ここで VPN クライアントを起動させられること、終了させられることを確認しておきます。

$ sudo ./vpnclient start
The SoftEther VPN Client service has been started.
$ ps -ef | grep vpnc
root       37803       1  0 18:21 ?        00:00:00 /usr/local/vpnclient/vpnclient execsvc
root       37804   37803  0 18:21 ?        00:00:00 /usr/local/vpnclient/vpnclient execsvc
nobi       37815   32744  0 18:21 pts/0    00:00:00 grep --color=auto vpnc
$ sudo ./vpnclient stop
Stopping the SoftEther VPN Client service …
SoftEther VPN Client service has been stopped.
$ ps -ef | grep vpnc
nobi       37823   32744  0 18:22 pts/0    00:00:00 grep --color=auto vpnc
$

これは無事にインストールできていることの最低限の確認です。ここまではやっておきたいところです。作業的にも一段落ですから。

ついでにもう 1 個のテスト

vpncmd を起動して Check コマンドを実行することで SoftEther VPN の動作確認をすることもできる。以下のような感じだ。参考にしてほしい。

$ sudo ./vpncmd start
vpncmd command - SoftEther VPN Command Line Management Utility
SoftEther VPN Command Line Management Utility (vpncmd command)
Version 4.34 Build 9745   (English)
Compiled 2020/04/05 23:39:56 by buildsan at crosswin
Copyright (c) SoftEther VPN Project. All Rights Reserved.

By using vpncmd program, the following can be achieved.

1. Management of VPN Server or VPN Bridge
2. Management of VPN Client
3. Use of VPN Tools (certificate creation and Network Traffic Speed Test Tool) 

Select 1, 2 or 3: 3

VPN Tools has been launched. By inputting HELP, you can view a list of the commands that can be used.

VPN Tools>?
You can use the following 6 commands:
 About         - Display the version information
 Check         - Check whether SoftEther VPN Operation is Possible
 MakeCert      - Create New X.509 Certificate and Private Key (1024 bit)
 MakeCert2048  - Create New X.509 Certificate and Private Key (2048 bit)
 TrafficClient - Run Network Traffic Speed Test Tool in Client Mode
 TrafficServer - Run Network Traffic Speed Test Tool in Server Mode

To reference the usage for each command, input "command name ?" to view a help.
The command completed successfully.

VPN Tools>Check
Check command - Check whether SoftEther VPN Operation is Possible
---------------------------------------------------
SoftEther VPN Operation Environment Check Tool

Copyright (c) SoftEther VPN Project.
All Rights Reserved.

If this operation environment check tool is run on a system and that system passes, it is most likely that SoftEther VPN software can operate on that system. This check may take a while. Please wait…

Checking 'Kernel System'…
              Pass
Checking 'Memory Operation System'…
              Pass
Checking 'ANSI / Unicode string processing system'…
              Pass
Checking 'File system'…
              Pass
Checking 'Thread processing system'…
              Pass
Checking 'Network system'…
              Pass

All checks passed. It is most likely that SoftEther VPN Server / Bridge can operate normally on this system.

The command completed successfully.

VPN Tools>exit
$

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください