banner
chensu

chensu

Server Rescue Memo

August 11, 2023, Monday.
This is a sad day,
When I arrived at work in the morning, I found that my computer was in a crashed state. After a series of troubleshooting, I concluded that the system disk was damaged. Every time I restarted, the system disk could not be read. During this hour of troubleshooting, there was one time when it started normally, which made me naively think that the previous inability to start was an accident and now it has returned to normal. So after starting up, I started working, but who would have thought that less than 10 minutes later, it directly displayed a system exception and then restarted.
After that, it couldn't be read anymore. I contacted the computer repairman and he said that the solid-state drive was broken and needed to be replaced. With this, a lot of data was lost. Although most of the data was backed up with OneDrive, some software data was lost, and I still don't remember what was lost, including the server login information saved in FinalShell. Actually, I wanted to log in to the server to update the memos. This guy updates too fast. It's fine for domestic servers, you can directly change the password. But there are also two Oracle servers, which I used to log in with private keys.

Trigger#

Fortunately, after searching for a long time, I found the private key for logging in on the D drive. However, because of this incident, I had the idea of changing the server to use account password login. I had been thinking about it before, but it was put on hold. Today, when I tried it, something went wrong.

Consequences#

After searching on Baidu for several articles on how to change the Oracle free cloud server to use account password login for SSH, I started following the steps. I have been playing with servers for two or three years, and I have some basic knowledge. In theory, changing to password login should not be difficult. But in the end, after finishing it, I found that I couldn't log in anymore, whether it was with a private key or a password.
What should I do? What should I do? What should I do?
My mind was full of question marks. At that time, I thought that at worst, I wouldn't be able to achieve password login, but who could have imagined that I couldn't even log in to the server in the end.
After some searching, I found that the SSH port was closed. This encountered a problem. To enable the port, I must first log in and operate, but to log in, the port 22 must be open.

Solution#

I was thinking if I could log in through another port. After searching on Baidu and trying it out, I found that it didn't work.
What should I do? What should I do? What should I do?
I was still in a state of confusion. Few people would encounter this situation.
I decided to ignore it and reviewed it again in the afternoon. There were basically no problems with the operations at that time. The only possible problem was when I entered vim /etc/ssh/sshd_config and added PermitRootLogin yes # Allow root login PasswordAuthentication yes # Enable password login in it.
So I was thinking, how can I restore this file to its previous state before the modification.
Actually, at that time, I had the idea of resetting the server, but fortunately, I came up with a solution in the end.
Because besides closing port 22, many other ports were still open, so I could log in to the Baota panel normally. After logging in, I opened the sshd_config file and looked through it, but I didn't find anything wrong. I couldn't understand it at that time, and I thought of trying something desperate. I copied and pasted the file from another server here, and then restarted the server, but it still didn't work.
Do I really have to reset the server?
I tried to search again to see where the problem was. I found this article, Linux modifies the default SSH port 22. I tried removing the # in front of 22, and found that the port was actually open.
I didn't understand this point. The other server also had a # in this place, but I could log in normally. This server must have had a # before today's tinkering, but I still don't understand what went wrong.

Result#

I don't understand, so I won't continue. As a civil engineering student, why bother understanding these things? As long as I can log in without resetting, it's fine.

Summary#

  1. Always back up your computer. Data is priceless, and it will be troublesome if it is lost.
  2. Don't tinker with servers too much. Work is important. Tinkering wastes time. It's better to read more books when you have time.
  3. Sort and archive the data in your hands as soon as possible. It's too scattered now, it's everywhere, and it's inconvenient to find things. And I don't even know what's missing.
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.