How To Use SSH To Connect To Your Server Securely [Guide]

How to use ssh is something that is not expected from any regular WordPress user. They prefer to access their website either through the WordPress dashboard or using FTP clients like Filezilla. But many of the users are unaware of the fact that apart from these regular methods, there is also a more secure and fast method available through which a user can access their website server more securely.

Hence, it can be one of the best and most valuable alternatives to accessing WordPress files from the server. Especially, if you want to boost up your work, you will find learning how to use SSH can be a worthy and efficient method to connect.

In this article, You will get to know How to use SSH in detail, but before that, you must clear some basic points about SSH. Let’s begin.



What is SSH?

SSH or Secure Shell is defined as a set of rules or protocols that is used to remotely access through secure login with other secure network services over an unprotected or insecure network. It means, through this protocol, you will be able to remotely access your WordPress website using valid login credentials from any device, no matter where your website has been hosted. The plus point of using this method is its security.

SSH provides you protected path through which you can log in to your website securely and become carefree from being the risk of unauthorized access while using it. In addition to this, it is way faster and easier to use than any other method.

However, any user who likes to connect to their website server mainly requires two things:

  • Login Credentials
  • Interface

For Windows users, you need to download and install an SSH client, but if you are running Linux or macOS you are not required to install any SSH client, an SSH interface has been built into these operating systems.

If you’re running Linux or macOS, you have an interface built into your operating system, so you don’t need to install an SSH client. But if you’re running Windows, you’ll need to install a client. I’ll show you how to do that in this post. Let me show you what tools you will require to connect to your website through SSH.


What Tools Do You Require To Connect To Your Website Through SSH?

To begin with the process of How to use SSH?, the first thing you need to use is a terminal (especially for macOS and Linux) or an SSH client for the Windows operating system.

How to use SSH, Using Terminal to connect your website on Linux or macOS

The terminal is an SSH application that comes with Linux or macOS operating systems. Through it, you will be able to send commands to your machine or a remote server using the command line. You may find it difficult at first due to its interface because you won’t be able to see any such representation on the screen. But when you learn it, it becomes handy and quicker for you.

The user interface is somewhat similar to Microsoft’s Disk Operating system in the early days. If you had used that, then you don’t find the terminal interface even more difficult. In addition to it, Terminal has a lot more options than MS-DOS has.

To locate and open Terminal on Mac OS, the first thing you need to do is to Open your Spotlight and Type in Terminal. However, you can also locate it by going to your Applications section and clicking on Utilities.

In Linux, You can directly open the terminal by directly pressing this shortcut key [ctrl+alt+T] or you can search it by clicking the “Dash” icon, and typing in “terminal” in the search box.

How to use SSH using SSH Client to connect your website on Windows

In Windows, first, you will need to install an SSH client through which you can only be able to connect to your website server. The best and widely used SSH client is PuTTY, you need to first download it and then install it.

How to use ssh using Putty
How to use SSh: Download Putty

How to use ssh client Putty on Windows?

As I have already mentioned above, the first thing you need to do is to download and install the Putty SSH client from the above download link provided.

PuTTY download Page
How to use SSH: Download Putty

Now from the above image, you can choose the right package that is compatible with your version of Windows. If you are not aware of your Windows Version, you can check it out in your Windows Settings.

Windows Settings page
How to use SSH: PC specifications

Once you can figure out which Windows version you have installed on your PC, choose the package accordingly.

Under the MSI section, you can now click on one of the links that match your Windows version, and the file will immediately download to your PC. Once downloaded, install the application.

After successfully downloading and installing the PuTTY SSH client, run the application and use it to connect to your website.


How To Use SSH Connecting Your Server Using Command Line

Now when you have successfully installed SSH client on your Windows machine or configured terminal SSH in your macOS or Linux. It is time to connect to your remote site. To connect either of these ssh clients, you have to use the command line, which is used to send commands over to your server.

But to make this possible, you will need some vital information such as:

  • Your Server Address
  • Your Username
  • Password
  • Port

Now you do not have a different server address required, it is usually your either domain name or the IP address. The username and password will be your FTP credentials. Whereas the port will be provided by your web hosting service provider. But generally, the port is taken as the default port.

In WPOven, You can access your site via an SSH command-line console by following these steps :
Step 1: You first need to enable SSH access for the site. To do this you need to access the site from the WPOven dashboard.

How to use SSH: WPOven enabling SSH
How to use SSH: WPOven enabling SSH

Navigate to the ‘Tools’ section.

How to use SSH: WPOven enabling SSH
How to use SSH: WPoven Tools

Then from the ‘Tools’ section, you need to press the ‘Enable SSH access’ button at the bottom of the page.

How to use SSH: WPOven enabling SSH
How to use SSH: Enable SSH access

Step 2: Once the SSH access is enabled for the site, you can then log in via 3rd party applications like Putty or PenguiNet using your site’s SFTP login credentials

To find out what your site’s SFTP login credentials are in WPoven:
Step 1: Open the “Sites” tab and choose the Site you want to know the details of.

How to use SSH: WPOven enabling SSH
How to use SSH: WPOven enabling SSH

Step 2: Click on the “Advanced” sub-tab, enter your WPoven login password, and click the “Show Site SFTP Details” button.

How to use SSH: WPOven enabling SSH
How to use SSH: WPOven enabling SSH

Step 3: After entering the password you will see all the required details you require to gain SFTP access to the site.

How to use SSH: WPOven enabling SSH
How to use SSH: WPOven enabling SSH

Interacting with your website using SSH

Now when everything is set up, it is time to connect your SSH client with the remote server. For your information, numerous SSH commands can be used and all of them are mentioned in WP-CLI( WordPress Command Line Interface).

One thing you must note is that you must be careful and take all necessary precautions while connecting your website via SSH, and do not disclose your login credentials to anyone else. It is because, SSH is a very powerful tool that even a slight mistake can lead to your website damage, and can also delete files even with a wrong command.

All images, posts, and content on your website can be deleted and lost with just a single command. The only thing you can do as a precautionary measure is to always keep a backup of your website and be cautious while using it.

How to use SSH using Some important and Basic SSH commands?

Since, I have already mentioned in the above section that SSH comes with numerous commands, with the help of which you can interact with your server.

When you are successfully able to get access to your server using the command line, now everything will be the same, just use Terminal to interact.

Check out some of the most basic and useful SSH commands you must look at. Get familiar with how to use SSH using the following commands:

  • To change directories use the “cd” command.
  • To get a complete list of files and directories in your present location use the “1s” command.
  • To copy files and folders using the “cp” command.
  • To add a new file in a new directory use the “touch” command.
  • To display the contents of a file using the “cat” command.
  • To move or copay a file from one destination to another use the “mv” command.
  • To remove a file or folder use the “rm” command.
  • To create a new directory use the “mkdir” command.

1. The “cd” Command

The cd command is used to change the directions across the directories. You can move to the location of the directory and the command line will show your location. After that, you can also figure out easily what is present in the new directory by using simply the 1s command line.

Using the cd command line you can move either down the directory or move up, All you need to add dots, for example, if you like to move up the directories, add two dots after cd.

cd ..

Even, you can also go directly to the specific directory location by adding the location after cd.

2. The 1s Command

This 1s Command is used to get all the detailed information of a particular directory or the directories in which you are present. You can also add more to the command to get in-depth information about that particular directory. Such as:

  • When you add the -a command along with the 1s command line, it will show all the hidden files and directories of that particular location.
  • When you add the -1 command along with the 1s command line, it will display all the details of the files such as size, permissions, date and time of modification, and the owner name.

3. The cp Command

From the name itself, you can anticipate the cp command is used for copying files and folders. To make this happen, all you need to do is to add the name of the file or folder along with the name of the location, where you want to copy a file or folder.

cp [options] [source] [destination]

From the above code, you can see, that you can also add options at the beginning of the command line, however, it is not mandatory to mention them. In addition, you must not add a name to the destination file or else, if you do so, and if there is a file already present with the same name at the destination, then it will be overwritten with the new one.

On the other hand, if you do not mention the file name in the destination and if the destination is already occupied with a file, then it will show you an error message and a copy will not happen

4. The touch Command

The touch command lets you add a new file when you create a new directory.

touch style.css

5. The cat Command

The cat command is used to display all the contents of a file in Linux.

Input:

cat testfile.txt

Output:

Displays the content of testfile

6. The MV Command

If you do not want to copy the file instead of moving it from one location to another, then the mv command will help you out. To do this, you need to provide the source and destination location without any options.

mv /themes/theme1/header.php /themes/theme2/

Unlike the copy command, the mv command will delete the header.php file from theme1 and move it to theme2. If you want to move folders instead of files, the mv command will always move the files in the folder as well.

7. The rm Command

The rm command or remove command is used to remove a file or folder from the directory. You must be careful while using this command, it is because this process is irreversible.

rm style.css

8. The mkdir Command

To create a new directory, you can use the mkdir command. For example, if you are located in the themes directory, you can make a new directory in it.

mkdir mytheme

YOU can also use the WP-CLI interface to connect

You can also use the WP-CLI interface which has more commands than typical SSH commands. It has options to interact with folders and files, database, and admin options too.


Read: 🚩 For more information about WP-CLI, you can go through
The complete guide to master WP CLI“.


What to do if SSH does not work as expected?

In some cases, you might face some issues with SSH. You might face some errors or some commands will not work as they should. If that happens to you, you must try the following tricks to resolve issues.

Unable to establish a connection with SSH

If you are unable to connect with your server and whenever you try an error message prompts on your screen. Either the prompt message will ask you yes or no or you must check if is there any syntax error. If still, it still doesn’t work, you must check out the username and password if they are correct or not.

If still the error persists, the next thing you can try to reset your SSH credentials. Check if your firewall is blocking you from accessing your server and whether your internet connection is good or not. If things are not still working, you can even restart your SSH client.

You must also go to your web hosting account and see if any server issues are restricting you from getting access. However, if your network is public, you may be not allowed to gain SSH access through the port. You have to use the trial and error method to determine which port allows you and which does not.

At last, doing all the efforts still, you are unable to connect with SSH, the only last thing you can do is to contact your hosting service provider and ask them to resolve this issue as soon as possible.

SSH commands are not working

What if your SSH commands are not working or behaving the way they should? This can happen mainly due to syntax error or you enter the command wrongly.

In some cases, you might be entering the correct syntax or command but still, you get an error message. This can be due to, you providing the wrong parameters. In this scenario, you must check out your SSH as well as WP-CLI documentation.

However, the best part about the command line is, that it will provide you with information about what things are working and whatnot. for example, if SSH commands are not working due to a connection issue, the command line will display an error message telling the same. It will give you more detailed information about the same.


Add an extra layer of protection to the SSH connection

You can also provide an extra layer of protection or security key by Generating an SSH key pair. Unlike your regular Username and password, that you use to connect to SSH, the security key is required to connect your server through a Terminal or SSH client.

Generate SSH key
How to use SSH: Generating SSH key pair Online

Steps to Generate SSH key pair:

  • With WPOven, you can generate a key very easily, go to the link provided put in your password, and click on the “Create key button“.
  • Now add the key to your Web hosting service account.
  • Connect to your server in Terminal or your SSH client using the key pair.

Summary

This detailed article on How to use SSH will provide all the information regarding using SSH to connect to your server. Now you will be no longer dependent on your regular WordPress admin page and FTP client.

Following all the steps and reading detailed information on How to use SSH, will help you to explore more things other than the common things that you used to Till now.

Now, you must try out this method and let us know Which one you would prefer. Please let us know in the comment section below, we love to hear from you.


Frequently Asked Questions on How to Use SSH?

What is SSH and how do you use it?

SSH or Secure Shell is defined as a set of rules or protocols that is used to remotely access through secure login with other secure network services over an unprotected or insecure network. It means, through this protocol, you will be able to remotely access your WordPress website using valid login credentials from any device, no matter where your website has been hosted. The plus point of using this method is its security.
SSH provides you protected path through which you can log in to your website securely and become carefree from being the risk of unauthorized access while using it. In addition to this, it is way faster and easier to use than any other method.

How do I use SSH?

If you are a Windows user, you can use SSh to connect your website via SSH client Putty or if you are a Linux user, you need to use Terminal.
Step 1: Open the Terminal Interface on your Computer.
Step 2: Type in the following command “ssh your_username@host_ip_address”.
Step 3: Provide or Type your password And hit Enter
Step 4: For the new connection, the client will ask if you want to continue connecting.

What is SSH command?

SSH commands are a list of instructions that use the SSH client to respond as per the given instruction. These commands provide a secure and protected connection between two hosts on any network. The connection can be used either to transfer, read, write, or remove files from the server. Some common SSH commands are:
To change directories use the “cd” command.
To get a complete list of files and directories in your present location use the “1s” command.
To copy files and folders using the “cp” command.
To add a new file in a new directory use the “touch” command.
To display the contents of a file using the “cat” command.
To move or copay a file from one destination to another use the “mv” command.
To remove a file or folder use the “rm” command.
To create a new directory use the “mkdir” command.


Leave a Reply

Your email address will not be published. Required fields are marked *