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 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 is available through which a user can access their website server more securely.

Hence, it can be one of the best and more valuable alternatives to access 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 defines as a set of rules or protocols which 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 protect 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 it, it is way fast and easier to use than any other method.

However, for any user who likes to connect to their website server, they mainly required two things:

  1. Login Credentials
  2. Interface

For Windows users, you need to download and install an SSH client, but if you are running Linux or macOS you do not require 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 You will required 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 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. And through it, you will be able to use 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 will 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 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 click on Utilities.

In Linux, You can directly open the terminal by directly pressing this shortcut key [ctrl+alt+T] or you can search it up by clicking the “Dash” icon, 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 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:

  1. Your Server Address
  2. Your Username
  3. Password
  4. Port

Now you do not have a different server address required, it is usually your either domain name or the IP address. And 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.

ssh 1 How To Use SSH To Connect To Your Server Securely [Guide]
How to use SSH: WPOven enabling SSH

Navigate to the ‘Tools’ section.

ssh 2 How To Use SSH To Connect To Your Server Securely [Guide]
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.

ssh 3 How To Use SSH To Connect To Your Server Securely [Guide]
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.
select site How To Use SSH To Connect To Your Server Securely [Guide]

Step 2: Click on the “Advanced” sub-tab, enter your WPoven login password and click the “Show Site SFTP Details” button.
sftp database details 0 How To Use SSH To Connect To Your Server Securely [Guide]

Step 3: After entering the password you will see all the required details you require to gain SFTP access to the site.
sftp database details How To Use SSH To Connect To Your Server Securely [Guide]

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 with 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 of 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 into your server using the command line, now everything is will be the same, just you use Terminal to interact.

Check out some of the most basic and useful SSH commands you must look upon. And get familiar with how to use ssh using the following commands:

  1. To change directories use the “cd” command.
  2. To get a complete list of files and directories in your present location using the “1s” command.
  3. To copy files and folders using the “cp” command.
  4. To add a new file in a new directory use the “touch” command.
  5. To display the contents of a file using the “cat” command.
  6. To move or copay a file from one destination to another use the “mv” command.
  7. To remove a file or folder use the “rm” command.
  8. 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 of 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.

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 -a command along with 1s command line, it will show all the hidden files and directories of that particular location.
  • When you add -1 command along with 1s command line, it will diplay all the details of the files such as, size, permissions, date and time of modificaiton and the owner name.

3. The cp Command

From the name itself, you can anticipate the cp command is used for copy 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.

From the above code, you can see, you can also add options at the beginning of the command line, however, it is not mandatory to mention them. In addition to it, 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 destination and if the destination is already occupied with a file, then it will show you an error message and copy will not happen

4. The touch Command

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

5. The cat Command

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

Input:

Output:

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.

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.

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.

YOU can also use 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.

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 be. If that happens with 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 is there any syntax error. If still, it 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 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 provide the wrong parameters. In this scenario, you must check out your SSH ass well as WP-CLI documentations.

However, the best part about the command line is, 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 and detailed information about the same.

Add an extra layer of protection on SSH conection

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:

  1. With WPOven, you can generate key very easily, go the link provided and put your password and click on “Create key button.
  2. Now add the key to your Web hosting service account.
  3. 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 dependant 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 defines as a set of rules or protocols which 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 protect 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 it, it is way fast and easier to use than any other method.

How do I use via 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.
Step1: Open Terminal Interface on your Computer.
Step2: Type in the following command “ssh [email protected]_ip_address“.
Step3: Provide or Type your password And hit Enter
Step4: 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 using 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 *