[CentOS 8] About the work when rebuilding ConoHa VPS

Introduction

I'm addicted to ssh related work, so I'll write it as a memo for myself. It is assumed that the server that was once managed will be rebuilt. This time, the root user is doing all the settings.

environment

[Client side] ・ MacBook Air (Retina, 13-inch, 2020) ・ MacOS Catalina (v10.15.7)

[Server side] CentOS Linux release 8.2.2004 (Core)

1. Stop and rebuild the server

From control panel> server> server rebuild in conoha. It is assumed that the same ssh key will be used.

2. Allow the IP address of the connected pc

Use the console on the conoha side to allow the server to allow the IP address of the network used by your PC to connect to. You can check the IP address of the network here. https://www.cman.jp/network/support/go_access.cgi

##conoha console side
## "xxx.xxx.xxx.xxx"Is the IP address of your PC's network
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="xxx.xxx.xxx.xxx" port protocol="tcp" port="22" accept"

3. Access with ssh

Use your key to access your VPS. For the IP address, use the VPS address instead of the IP address of your PC network that you used earlier.

##Input at the terminal on your PC side
##Enter the IP address of the VPS in the IP address field

ssh -i kagi.pem [email protected]

##The route to the key depends on where you store it
##If the key is placed on the desktop on mac, the image below
## ssh -i /Users/xxx(username)/Desktop/kagi.pem [email protected]

4. Rejected

If you rebuild with the same IP address as the server you built last time, you should get a warning and cannot access it.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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)!
...(Omission)....
Host key verification failed.

When connecting to the server with ssh, it seems that the connection destination information is saved locally, but in this case the server information is the last time even though it is connected to the same IP address destination. I am angry that it is dangerous to access because it is different from when connecting.

5. Delete the local destination information

Clear the connection destination settings in the .ssh folder.

##Input at the terminal on your PC side
## .To ssh folder
cd
cd .ssh

##Delete settings Enter the IP address of the VPS in the IP address field
ssh-keygen -R xxx.xxx.xxx.xxx

I was able to erase the information about the last server I was connected to.

6. Connect again

##Input at the terminal on your PC side
##Enter the IP address of the VPS in the IP address field

ssh -i kagi.pem [email protected]

7. Warning about fingerprint

You may get a warning again.

The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established.
...(Omission)...
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Enter yes. Login is complete.

At the end

It is very important to take notes because there are few opportunities to experience building an environment. The links and information I used to write down in my memos were useful.

Sometimes I stumble in the same place as before ...

Reference link

When I make an ssh connection, I can't connect with "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!"

Ssh connection from Mac terminal to instance of Lightsail

Recommended Posts

[CentOS 8] About the work when rebuilding ConoHa VPS
About the procedure for java to work
About the speed when fetching values from HashMap
Prepare the environment of CentOS 8 with Sakura VPS
About the mechanism when displaying the GUI with Docker
About the method
About the package
About Class loading and initialization when the JVM starts
When the vagrant command doesn't work for some reason