【ConoHa VPS】SSH接続でリモート操作する方法

ConoHa VPSで立てたサーバーをSSH接続でリモート操作する方法についてまとめました。

スポンサーリンク

「WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! 」エラーでSSH接続失敗する場合の対応方法

● 接続情報が以前の接続情報と違うと異なると、SSH接続を試みた際に以下のエラーが出てしまいます。

$ ssh -i ~/.ssh/xxxxxxxxx.pem root@xxx.xxx.xxx.xxx
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:XXXXXXXXXXXXXXXXXX/XXXXXXXXX.
Please contact your system administrator.
Add correct host key in /Users/XXXXXXXXX/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/XXXXXXXXX/.ssh/known_hosts:2
Host key for xxx.xxx.xxx.xxx has changed and you have requested strict checking.
Host key verification failed.

● PC側でターミナルを開いて以下のコマンドを実行します。
これで、以前の接続情報を削除します。

$ ssh-keygen -R xxx.xxx.xxx.xxx

# Host XXX.XXX.XXX.XXX found: line 2
/Users/XXXXXX/.ssh/known_hosts updated.
Original contents retained as /Users/XXXXXX/.ssh/known_hosts.old

● これでSSH接続を再度試みると、接続できました。

$ ssh -i ~/.ssh/XXXXXXXX.pem root@XXX.XXX.XXX.XXX


The authenticity of host 'XXX.XXX.XXX.XXX (XXX.XXX.XXX.XXX)' can't be established.
ED25519 key fingerprint is SHA256:XXXXXXXX/XXXXXXXX
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'XXX.XXX.XXX.XXX' (ED25519) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/XXXXXXXX/.ssh/XXXXXXXX.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/Users/XXXXXXXX/.ssh/XXXXXXXX.pem": bad permissions
root@XXX.XXX.XXX.XXX's password:
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-70-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon 10 Jan 2022 03:53:26 PM JST

  System load:  0.08               Processes:             105
  Usage of /:   17.4% of 29.40GB   Users logged in:       1
  Memory usage: 40%                IPv4 address for eth0: 118.27.32.222
  Swap usage:   0%

 * Introducing self-healing high availability clusters in MicroK8s.
   Simple, hardened, Kubernetes for production, from RaspberryPi to DC.

     https://microk8s.io/high-availability

180 updates can be installed immediately.
90 of these updates are security updates.
To see these additional updates run: apt list --upgradable


Last login: Mon Jan 10 15:07:04 2022
root@XXX.XXX.XXX.XXX:~#
【ConoHa VPS】LinuxOSサーバーを手軽に運用する方法
ConoHa VPSでLinuxOSサーバーを手軽に立てて運用する法についてまとめました。
Linux
スポンサーリンク

コメント