Alternative to ssh tunnel in centos 9
i accidentally ran chmod +x from root in /
that caused sshd to get corrupted and server wouldn't start again. tried a lot of options but nothing seems to work.
there are some important files in that server, how can i get a copy of those files without manaually reading those files in weblish.
thanks
2 Replies
✓ Best Answer
I'm not sure what options you've already tried, so forgive me if I'm just repeating what you've already done, but here are some suggestions that may help:
Copying Data
Even if SSH isn't working, you may be able to Copy your disks over SSH using that guide. Because your server will be booted in Rescue Mode, whatever issues this caused may not affect those steps in that environment.
Troubleshooting SSH
I wasn't able to find a great way to get data off your server without SSH access, so restoring that access may be worth a try.
I tried to recreate this, in order to break sshd on my test server, which was running CentOS 7, I had to run that command with the recursive flag. Otherwise, it didn't cause any issues that I could see. But once it was broken and I couldn't access it over SSH, I logged in the LISH Console and removed the execute permission from the file that seemed to be causing the problem by running this command. I was then able to access the server again.
chmod -x /usr/sbin/sshd
While you may need to make other changes, it does seem like it might be something you can fix from LISH. These guides may be helpful for that.
I also wanted to note that using LISH can be really frustrating because finding the file you need to change is difficult without being able to scroll. If you list out the contents of a directory and need to scroll up to find what you need, you can press CTRL-A + ESC to enable scrolling.
Restoring from a Backup
Another possible solution is to restore from a backup of your instance that was made before the command was run. If you use our Backups Service, you can do that using these guides:
- Restore a Backup to an Existing Compute Instance - for this, you could restore to the instance that was broken
- Restore a Backup to a New Compute Instance if you choose this option, you could make a new server and then once you're sure it's working, you can swap IP addresses to get any old IPs onto the new server. If you go with this option make sure you take steps to Stop Further Billing on any unused instances.
Hopefully you're able to resolve this, but I'd recommend taking steps to backup your data in the future if you're not already doing that. These guides offer some options for doing that.
Thanks Cassandra, i did run that fateful chmod +x recursively and ended up in this situation.. i didn't try chmod -x for sshd, dont know why but ended up doing everything else in the world.. its too late now for me to try that and i accepted my punishment by god to read code from lish and re-code in new server.
thanks for your elaborate answer, i will try your solution if i screw things up next time, which would be in next life for sure
thanks and regards