Sometimes you just need to upload a file that is bigger than the web interface will allow. Or do something on your server that will take longer than the script timeout on SiteGround. A prime example of this would be the WordPress cron commands which could easily take longer than the script timeout.
If you find you’re in any of these situations, all is not lost. For copying large files to and from your server you can use SFTP or SCP. For longer commands you can use SSH. But it’s not particularly easy to setup. Once it’s setup it’s very easy to use though. So in this tutorial we’ll go over how to set up easy SSH access to your SiteGround website from Windows 10. The process is largely the same for MacOS or Linux users though you won’t need the first two steps.
How To Setup Easy SSH Access to your SiteGround Website from Windows 10
- Turn Windows Features On Or Off
WSL gives you access to all manner of Linux commands under Windows. It’s my preferred way of getting SSH access working although you can install an SSH terminal emulator such as PuTTY instead. I just prefer WSL because I use it for other stuff too.
To install WSL type turn windows features into the search bar at the bottom left then click on the Turn Windows Features On Or Off line that comes up. The image below will show you what I mean.
- Turn on Windows Subsystem For Linux
The window that will open allows you to switch different features on or off. You need to scroll almost all the way to the bottom. There you’ll see Turn On Windows Subsystem For Linux. Put a tick in the box and click the OK button.
WSL will install and you may be asked to reboot afterwards.
- Install Ubuntu 18.04 LTS from Microsoft Store
You can choose to install a different Linux distribution if you prefer – but some of the commands given later in this guide will assume you have installed Ubuntu. You may need to modify them if you install something else.
When you run Ubuntu 18.04 LTS for the first time it will install all the files you need and may take 10 or 20 minutes depending on the speed of your internet connection. The image I have shown below shows that I already have Ubuntu 18.04 LTS installed – yours will ask you to install it rather than showing Launch.
- Open Ubuntu 18.04 LTS
From the start menu, choose Ubuntu 18.04 LTS – or type Ubuntu into the search area in the bottom left hand corner of your screen as shown in the image. Click on the link that Windows shows to start Ubuntu 18.04 LTS.
The first time you run this Windows will install all the basic requirements for suitable operations. It does this by downloading a fair bit of data across the internet so make sure you’re on a good internet connection. It could take around 10-20 minutes depending on the speed of your connection.
- Install SSH client on WSL Ubuntu 18.04 LTS
Now that you have a WSL install – effectively you are running Linux within your Windows system. Now you can download and install Linux packages on to your Windows computer.
To do this, Ubuntu uses a system it calls APT (Advanced Packaging Tool). To install SSH type the following command into your Ubuntu 18.04 LTS Window.
sudo apt install ssh
You will need to input your password, which you will have given during the initial setup phase of installing Ubuntu 18.04LTS. Once entered correctly, the SSH package will be downloaded and installed. It should all look something like the screenshot below;
- Generate SSH Keys
Using the WSL Ubuntu console again, type the following command;
Press enter after you type the command and follow the prompts. You can call the key whatever you like, but it’s usually best, if you only have the 1 key, to call it the default name. To stick with the default you can just press enter. In the screenshot below I have called mine myKey as I already have a key called id_rsa. But you should stick with id_rsa.
It’s advisable to enter a password if your computer can be accessed by anybody else. Otherwise they’ll have instant non-password access to your SiteGround hosting as well.
- Copy SSH public key
SSH uses two separate keys. The private key, which should only ever be on your local machine. The public key can be shared with any service you wish to log in to. It’s a bit confusing, but remember that the private key should remain private to you. The public key is what you need to upload to a public (ie, not yours) server to enable access.
To copy the public key type the following commands in your Ubuntu Terminal;
You don’t need the ls part, it’s just to make sure you know what the public key is called. If you know for sure you can skip that bit. The ‘cat’ command will display the contents of the id_rsa.pub file. You can then highlight the contents by dragging your mouse over the displayed text. It will automatically be copied to the clipboard. We’ll use that copied data in the next step.
- Upload Copied SSH Public Key to SiteGround
Make sure it’s the PUBLIC key you’ve copied. You do not want to upload the private key. Firstly, it won’t work. Secondly you just gave your private key to a public entity – you don’t want that.
Anyway, open up your SiteGround control panel and select Websites from the top tab bar.
Click ‘Site Tools‘ button on the website you want to login to. You may only have one website.
Click the ‘Hamburger’ menu option on the top left to open up the menu for your website. Then choose ‘Devs‘. You may need to be on the GrowBig or GoGeek plan for this to be available – I’m not actually sure if it’s available on the basic plan.
Under the ‘Devs’ menu you’ll see SSH Keys Manager. Choose that option. Then choose the Import tab. Paste your SSH Public key you copied earlier into the box as shown below. Give it a name and press the Import button.
- Setup SSH Config File For Easy Access
The username generated by SiteGround is a long string which you’ll struggle to remember. The Port is not standard for SSH either, which means that using SSH from the command line can get a bit unwieldy. But fortunately, SSH offers a convenient configuration file where you can provide an easy to remember hostname and the rest of the details will be filled in for you. To edit this, return to your Ubuntu Terminal.
From the .ssh directory type ‘joe config‘. Joe is the editor I use. You can use ‘vi config‘ or any other editor you prefer to use.
This will open up the editor where you can create a configuration entry for the SiteGround server. You can have multiple entries for different servers. It’ll look something like this;
Host is the friendly name you give to your SiteGround server. Hostname is the hostname given by SiteGround on the SSH Import screen shown in step 8. Copy the Username from Step 8 too and paste that into the configuration file next to User. I’ve blanked most of mine in the example above to reduce the chances of someone hacking it 🙂 Do the same with Port.
Save the file. Now, you should be able to type the ssh command below and get access to your server.
ssh snibbo (replace snibbo with the friendly name you specified in the config file next to Host)
If your private key was created with a password you’ll need to enter it before you can connect. If you left it blank you should be logged in to SiteGround via SSH.
The most common problem encountered with the steps shown above is one of incorrect permissions. SSH is very picky about permissions. Your config file and any private keys MUST be readable only by your account, not group or world permissions.
To change the permissions type the following command;
chmod 600 id_rsa config
This will set the permissions on id_rsa and config files to readable and writable by you only.
You may also need to change the permissions of the .ssh directory too. To do this type the following;
chmod 700 .
The directory needs to be read, write and execute by you only. 700 permission does this.
Hope all that helps – if you have any questions or comments please leave a comment below! Happy SSHing