Forum Moderators: bakedjake
I have a little situation that I'd like to get solve without taking a drive.
I a RedHat Linux server that I manage I was doing a config change in /etc/ssh/sshd_config. Unfortunatly the change I made was not supported in this linux version. I got an error but ofcourse SSH restarts only restart the parent process.
Well I fixed the problem and then issued a restart again (stupid me) anyway it happily killed my session and unfortunatly didn't restart properly.
Now I have no more SSH until I come up with something inventive or make a trip down to the co-lo and fix it at console.
I still have ftp (not root ofcourse) and all my services are running (ie apache mail etc etc) so this is not a serious think. So my though is create a script that runs the commands to fix ssh (ie /etc/rc.d/init.d/sshd restart and maybe copy a simple default sshd_config that I know will work)
Ok I can get that on the server. Set +x with ftp and get it to run from a url but I'm still missing one thing. It's not running as root.
That brings me to the root (forgive the pun) of my problem. I could run "su" but then it asks for a password which I can type in. Well I gave expect a try and (yes I know it's bad) in my expect script I put the root password.
Unfortunatly this still does not work. Anyone around here have any ideas to save me a drive this weekend :)
daisho.
What you could do to avoid this in future is write a (password protected) cgi script which write a file to a specific location. Then write a bot (which runs from cron as root) which checks if that file exits.
If the bot sees the file, you can have it do whatever you want. Restore the ssh config and restart ssh, reboot, whatever.
You can expand on that to have your cgi script write various files for various tasks you want it do execute. Then have your bot pick up the files and execute the tasks for each file.
Be sure to have your bot remove the file(s) after it runs.
You could take it a step further and have the file the cgi script writes be shell script, but that is not something I would fully trust or do (even with password protection).