In this tutorial we’ll introduce you to SSH – a tool that allows you to send remote commands to your Web server – and show you some simple UNIX commands to help you manage your website.
Not all Web hosts give you SSH access to your Web server. This is often for security reasons, or because the host is running a non-UNIX server such as Windows. If in doubt, ask your Web hosting company if they support SSH.
What is SSH?
SSH is a secure protocol that encrypts all data sent between the client computer and the computer it is connecting to. SSH applications usually allow both interactive terminal sessions on the remote machine and the ability to transfer files securely – For example, your Web server – and type commands to be carried out on that computer, such as moving and copying files, creating directories (folders), and running scripts. To talk to your Web server via SSH, you need an SSH client on your computer – see below – and you also need three pieces of information:
1. Your Web Server’s IP address or hostname
2. A username: This is the username that you’ll use to login via SSH. Often it’s the same as your Web Control Panel or FTP username.
3. A password: This is the password that’s associated with the above username.
If you’re not sure what to use for your hostname, username or password, check with your Web hosting company.
Connecting using an SSH client on Windows
There are many free and commercial SSH client programs available for Windows. A good, popular free client is PuTTY. To use it, simply download the putty.exe file, then double-click putty.exe on your computer to run it. You’ll see PuTTY’s configuration dialog appear:
Enter your Web server’s IP address or hostname in the Host Name (or IP address) box, and click Open. The first time you connect to your Web server, you’ll probably see a security alert dialog appear, warning you that PuTTY doesn’t know anything about the machine (“host”) that you’re connecting to.
Click Yes to add your server to PuTTY’s cache and proceed with the connection. You’ll now see a black terminal window appear, containing a “login as:” prompt:
Enter your username, and press Enter. A “Password:” prompt appears; enter your password and, again, press Enter. If all goes well, you’ll now be logged into your Web server. You’ll probably see some sort of welcome message from your server, followed by a shell prompt:
A shell prompt is a small piece of text that lets you know the server is waiting for you to type something. Often the prompt ends in a dollar symbol ($). In our case, the shell prompt is “matt@bart:~$“. This tells us that we’re logged in with the username “matt“, the computer’s name is “bart“, and we’re currently in our home directory (~).
You are now getting access to your server via SSH. You can try some basic command. In this case I’ll try to see RAM usage in my server by using command:
It will return like this:
Quick tip: In Putty, you can use mouse right-click to paste any text which is copied.
Connecting using an SSH client on Mac OS X or Linux
If you use a Mac or run Linux, you’re in luck, as Mac OS X and Linux both come with a built-in SSH client. To use it, you first need to open a terminal window. On Mac OS X, you can do this by double-clicking the Terminal application inside Applications/Utilities in the Finder. To open a terminal on Linux, consult your distribution’s documentation; usually it’s available via the applications menu.
Once you have a terminal window open, type:
Where username is your SSH username, and hostname is the host name or IP address of your Web Server. Then press Enter. If this is the first time you’ve tried to connect to this computer, you’ll see a warning to the effect that the host couldn’t be authenticated. Type yes and press Enter to confirm that you’d like to continue with the connection.
After a few seconds you should see a “Password:” prompt appear; enter your password and press Enter once again. You should now see a welcome message and a shell prompt, indicating that you’re logged into your Web server:
If you get an error message – such as “Access denied” – then your username or password is probably incorrect. As your Web hosting company for help.
This tutorial is written by Matt Doyle. I only collect more information and rewrite by my word for easier to understand. After finished reading this article, you should read: The Basic SSH Commands – List of Common SSH Commands. Read that post to know all basic Linux commands those are necessary to manage unmanaged server.