ケンヂまるは今、自分で作ったプログラムをウェブシステムとして公開するために、HTTPサーバーを準備しています。
今回はConoHaが提供しているVPS(Virtual Private Server)を使ってLinuxサーバーを作り、そこにSSHからログインするまでの手順をご案内します。

VPS初めの人にとってはサーバーを立ててログインするだけでも結構ハマりポイントが多いということで解説
ConoHaのVPSについて
このブログはConoHa WINGという超高速サーバーを使っているのですが、VPSも利用することができます。
CPU1コアのみのプランならお値段なんと1時間≒1円と、かなり安いです。

VPSを作成してから1時間だけ使って、すぐに削除してしまえば、発生する料金は1円だけ。
今回使用したVPSの環境
- ConoHa VPS
- Debian
- 1時間あたり1円の最安プラン
ConoHaのVPSでDebianサーバーとしてVPSを作成しました。
接続鍵を作成しておく
ConoHa VPSのコントロールパネル「セキュリティ」→「SSH Key」から、あらかじめSSHキーを作成し、秘密鍵(.pemファイル)をダウンロードしておきます。

今回は、vps-debianという名前のSSHキーを作成しました。
.pemファイルをダウンロードしたら、Windows以外の環境なら他のユーザーから参照ができないようにアクセス権を600に変更しておきます。
> chmod 600 vps-debian.pem

これをしておかないとsshクライアントで.pemファイルを指定した時にセキュリティ甘いと怒られる
VPSサーバーを作成
学習・テスト環境なのでプランは最も安いCPU 1Coreプランを選択し、OSはDebianにしました。
世界的にはCentOSよりDebian・Ubuntuの方がシェアで勝っていて、単体サーバーでUbuntuを選択するメリットが考えれなかったため、Debianでいいかという考えです。

ネームタグの下にあるオプションの中のSSH Keyを「キーを選択」にし、先ほど作成したSSH keyを選択します。

右側にある「追加」ボタンを押すとサーバーが追加されます。

サーバーリストに表示されるので、ネームタグのリンクをクリックします。

ネットワーク情報でIPアドレスが確認できるので、SSHでこのIPアドレスに対して接続します。

SSHで接続
SSHでVPSに接続しましょう。
.pemをカレントディレクトリに用意しておき、sshコマンドで接続します。
> ssh -l root -i vps-debian.pem 118.27.24.142
Linux 118-27-24-142 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Jul 12 06:57:20 2020 from 180.199.133.100
root@118-27-24-142:~#
とこんな感じで接続ができます。
後書きというか

使い終わったらVPSサーバーを削除しよう。
停止していても1時間1円発生です。