What is SSH?
SSH is a protocol that allows you to connect to a remote computer - 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:- Your Web server's IP address or hostname
- Often - but not always - the hostname is the same as your website's domain name.
- 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.
- A password
- This is the password that's associated with the above username.
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 (~).
Some basic commands
Congratulations! You've logged in to your Web server using SSH. You can now issue commands to the server by typing them in at the shell prompt:
The ls
command
ls
is short for "list"; it lists all the files and directories in your current directory (called the working directory in Unix parlance). Type ls and press Enter, and you should see a listing appear in the terminal window:username@webserver:~$ ls myfile.txt myfile2.txt mysite.com
The exact listing will, of course, depend on what files you have in your directory
on the server!
The cd
command
cd
stands for "change directory", and it allows you to
move into and out of directories, much like double-clicking folders on
your PC. For example, if mysite.com
listed above is the directory containing your website, you can move into the directory as follows:username@webserver:~$ cd mysite.com
You can then do another ls to list the contents of the
mysite.com
directory:username@webserver:~/mysite.com$ ls cgi-bin htdocs logs
To move back up a directory, use cd .. (
".."
means "the parent directory"). You'll then be back in your original directory:username@webserver:~/mysite.com$ cd .. username@webserver:~$ ls myfile.txt myfile2.txt mysite.com
Notice how our shell prompt changes to reflect our
current directory. Not all shell prompts do this; it depends how your
server has been set up.
The pwd
command
Often it's useful to know your exact current directory. To find this out, type the command pwd (short for "print working directory") and press Enter. The computer displays the full path to the current directory you're working in:username@webserver:~$ pwd /home/users/username/
No comments:
Post a Comment