Secure Shell (SSH) Overview

SSH is a way of connecting to your web space using the command line. You can manage files and run commands and for power users this is a really important feature. To use SSH, you must use an SSH client to connect to the server. Once connected, you can manually run commands within a terminal application.

With SSH, you use a terminal (or Shell) client to connect to the server.

  • On MacOs and Linux you can use Terminal.
  • If you are running Windows, you can download an SSH Client, such as PuTTy

If you have a command prompt, you can type ssh, followed by your shell username(cPanel username), an @ sign, then your server name. For example:

ssh [email protected]

Once you have logged in, you can then edit files, move files and run PHP commands and so on. Our system also supports key based authentication, which is more secure than using a password and saves having to type it every time. Just generate a private key on your computer, and then upload the contents of the public key part of it to a file called .ssh/authorized_keys. If you need any help with this, please don't hesitate to get in touch.

Now we will go over some basic commands after you have logged in.

Navigation

Three major commands to use when navigating your hosting space are:

pwd - this command will list the path you are currently in, so you don't get lost. The output will usually look like /home/user/public_html/example - this means you are in the folder "example".

ls -lah - this command will list the files in the folder you currently are, along with additional information about the files such as size, time and date it was last modified/created, permissions.

cd - this command is used to go to the relevant folder/directory.

Creating/modifying/viewing

mkdir [directoryname] - to create a new directory in the location you currently are.

touch [filename.ext] - to create a new file, please note you should put the extension at the end such as .txt for example.

You can modify files with one of two editors, by default nano is used more often by less experienced users.

ex: nano [filename].txt - this will open the file in nano, you can read full information on how to use it by pressing F1 or alternatively Ctrl+G.

You can also use vim to edit files, this editor is for more advanced users but if you take fancy to it you can also press F1 for help with commands once the file is open.

ex: vim [filename].php

You can view a file using cat - for example cat [filename.txt] will display in terminal the contents of filename.txt in text format.

TIP: You can use cat in combination with grep to find text inside a file, the content will be displayed but the requested text will be outlined in red so you can find it easier.

ex: cat [filename.txt] | grep "Nov 13 13:07" - translated: display contents of [filename.txt] break ( | is called pipe, separates different commands) grab and outline text matching "Nov 13 13:07" exactly.

If you search on google for a command and would like to try it, we recommend using this website to translate what the command will do: https://explainshell.com

It will help you have a better understanding of what you are using and perhaps in the future you will remember it and use it in other combinations together - it's excellent for learning.