Know Thy Server
I had one of those nightmarish days yesterday where one of my servers stopped responding (well two servers by the end of the day). This occasionally happens and normally can be resolved by connecting using WHM (Web Host Manager) and restarting the failed services or in the worst case a full reboot. However on this occasion WHM also failed to connect so I had a server that responded to pings and that was about it, damn!
The next thing to do in this event is raise a ticket with your hosting provider and put them on the case, this is where a good hosting provider can (and should) really excel. As this has happened to me before yesterday I decided it was about time I learnt a bit more about managing my server using SSH, the very basics of which I want to share in this post.
SSH stands for Secure Shell and you use it to run commands remotely your server. I am used to MS Windows so to me SSH is a bit like opening a remote DOS box on your server. I am becoming more diverse with my operating systems as I use Vista as my main office machine, a Mac Book Pro when I’m travelling on business and my EEE PC laptop running Linux when I’m travelling and there’s a high risk of it being nicked. So for each machine there is a different way of connecting:
SSH from a Microsoft Windows Box
On my Vista machine I’ve downloaded the freeware utility PuTTY which is a remote SSH/Telnet client. To use simply enter your hostname and then click open. You’ll then need to enter your username and password and if all goes well you’ll now have a terminal window to your server.
SSH from a Mac
On the Mac you’ll need to to open up a terminal window, to do this go to:
Finder -> Applications -> Utilities -> Terminal (you could drag the terminal down to the dock bar if you’ll be using it a lot)
Next to open a SSH session to your server enter the following in the terminal window:
ssh hostname.com -lusername
Where hostname.com is your domain and username is well you can guess that bit. You’ll now be prompted for your password
SSH from Linux
Connecting from Linux is like the Mac except to bring up the terminal window you just need to press CTRL+ALT+t and the rest is the same.
Web Based SSH
I’ve tried and used all the previous methods but there is also another option which is using a web based SSH client. I must admit I would only ever use one in an absolute emergency as entering passwords on a third party site is somewhat scary. If you’re in need though just do a search for web based ssh client.
Once logged in you have very powerful access to your server, where depending on security settings you can do just about anything (serious damage can be done so be careful). For me all I needed to do was restart the machine, when was accomplished by issuing the command reboot, two minutes later my server was back up and running at full steam. For a list of common SSH commands check out:
In total my server was down for about 30 minutes which will of cost money, subscribers and potentially a drop in SERPs. If I’d researched this before I could of reduced that downtime considerably and it would also of been much easier to learn at a relaxed pace rather than in mad panic. So if you have a dedicated server or VPS I’d suggest becoming familiar with at least the fundamentals, you never know when you might need them. I’d also like to send out a massive thanks to Keith for his advice and hand holding. I’m now off to buy a Linux book to read whilst I’m on holiday next week .
Related Posts:
I’ve taught myself a lot of things in a ‘mad panic rush’ like how to move my sql databases and all sorts of things I should have my sticky fingers on!
Yeah there’s nothing like mad panic to get the learning head on.
Is there a way to make a server output 503 errors if it goes down? That would mean no loss of serps…..
I don’t think there is a way when Apache drops (or IIS in the case of Windows) as each of those are responsible for putting up the errors and if they are down then they wont be able to do that.
You might be able to shorten your TTL on your DNS (so there are no long caches) and then some how make a script that detects when Apache (or IIS) has dropped and then change the DNS A record for WWW to automatically to point to another hosting account that always displays a 503 error. That could be just a cheap few $$ a month account or an account on another server if you have one.
I am sure there are other more expensive ways such as having load balanced servers, but it depends on how much money you could lose with 30 minutes downtime weather it’s worth it or not.
I currently pay $15/Month for my host to monitor my site every 5 minutes. If it drops then an urgent ticket is automatically raised and they sort it out with in minutes. I am not sure if 10 - 15 minutes would be a long time in the eyes of Google though… probably :S
That’s a good idea Matthew, I think I have that included in the price though for what ever reason that didn’t help this time.
The monitoring is done by Hyperspin (another company) and my host have an agreement with them and get contact automatically when it breaks.
Luckily it does work for me as I have needed it 3 times this week for some reason which I believe I have now fixed. I just wake up to 4 emails saying “site is down”, “ticket created”, “ticket responded to”, “site is back up” all with in 5 - 10 minutes from start to finish.
Who hosts your servers Al? What setup do you have for CG?
CG has a dedicated server with ASmallOrange in the States. I also have a UK based VPS with Clook for various UK orientated site and a number of reseller accounts for other sites that I have. I’ve probably got too many to be honest.
I don’t even know how many times Putty saved our butts!
> to bring up the terminal window you just need to press CTRL+ALT+t
Actually, that is not true - if you customize the shortcut, you will be able to bind Ctrl+Alt+T to terminal - but its not so by default.
If you are looking for a default shortcut, go for Ctrl+Alt+F1
And Alt+F7 to return.
Thanks Binny, I’m pretty new to all this (as you can probably tell). On the Asus it must be bound by defaukt as that’s what it does out of the box.
When your stuck behind a firewall (day Job) with SSH blocked it can be a pain, but I like the idea of Web Based SSH I must check if my webhost do this as that would seem the ideal support that they could do.
Also, if you’re on a mac and scared of terminal, you can download a freeware app called CyberDuck, and use a graphical interface like putty
Yup, I know that feel. Try to understand dos screen
I just request access for ssh access for work efficiency.
I’ve had to do this a few times, luckily my server seems to be a lot better behaved nowadays!
[...] to be a bit of a shorty, I’m off on holiday tomorrow and I again had server issues which my new found knowledge of SSH couldn’t fix (I could ping but nothing more). So the post I had planned for today will have [...]
I had such problems before as well and it really raises my heartrate whenever I receive an SMS that one of my servers went down.
Server Monitoring’s last blog post..Wordpress 2.6.1 released