August 11, 2023, Monday.
This is a sad day,
As soon as I started 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 computer, I couldn't read the system disk. During this hour of troubleshooting, there was one time when it started normally, which made me naively think that the previous inability to start up was an accident and now it's back 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, I can directly change the password. But there are also two Oracle servers, which I used to log in with a private key.
Cause#
Fortunately, after searching for a long time, I found the login private key in 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.
Consequence#
After searching Baidu for several articles on how to change Oracle's 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 I finished, 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 change to 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 had to log in and operate, but to log in, the port 22 must be open.
Solution#
I was thinking about whether 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.
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. At that time, I didn't understand it either. I thought about trying something desperate, so 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 find out where the problem was. Until I saw 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 troubleshooting, but I still don't understand what went wrong.
Result#
I don't understand, so I won't bother anymore. As a civil engineering student, why should I understand these things? As long as I can log in without resetting, it's fine.
Conclusion#
- Always back up your computer, data is priceless, once lost, it will be very troublesome.
- Don't tinker with servers too much, work is important, tinkering wastes too much time, it's better to read more books when you have time.
- 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.