How To Upload Local File or directory on Server using sFTP

The other day I had to upload a huge folder into my web-server (Traffic Planet Hosting) & instead of using desktop based FTP tools such as FileZilla or Cyberduck, I thought of taking advantage of their sFTP support.

It took me some time to try all the Unix commands for my Mac OS Terminal to get everything done  & I realized this thing is pretty useful when you are changing your hosting account. Moreover, most of the hosting companies offer sFTP & you can do a lot of things using it.

Last time I shared a detailed tutorial on the similar topic. You can read about it here. In that topic, I covered how you could move your WordPress site data from WPEngine to new hosting using sFTP command. In this tutorial, I will share all commands you need to upload a local file/files or directory to your hosting account using sFTP. In this case, I’m helping one of my friends to move his banned WordPress site from HostGator to Traffic Planet Hosting.

What happened with my friend site on HostGator?

If you are someone like me who love to read about WordPress hosting, you would know that HostGator being an economical hosting, is not appropriate for a high-value business site. One of the major drawbacks of HostGator hosting is the security.

I’m not saying that HostGator infrastructure is bad, in fact they offer one of the best resource in Shared hosting industry. But the problem is they are not very handy when your site is hacked. When running a WordPress site, you can be easily hacked because of using a nulled WordPress theme or an older version of a plugin. This is one reason, it’s always recommended to setup WordPress backup solution. This way, you can always recover your hacked WordPress blog.

In my friend case, HostGator banned his account showing this message:

What happened?

Over the last few hours, our monitoring systems have identified your account as requiring an inordinate amount of server resources. To ensure the continuing operation of both your server and your website, we have temporarily enabled an emergency caching solution to lessen the impact of your website’s resource usage.

What does this mean and how will it affect me?

Our caching system allows your site to remain available on the Internet without interruption by creating a static version of your content to present to all visitors. The static version will be updated every three hours. While the site is being cached, you may notice delays in the appearance of new content. Additionally, If you’re utilizing a CMS, (WordPress, Joomla, Drupal) you may also experience difficulty accessing the backend/dashboard/administrator panel of your website. This is expected behavior for a site that is utilizing emergency caching.

How long will this last?

Our caching system will automatically remove itself after 24 hours of normal server resource usage. However, if your website’s resource usage continues to be an issue it may be permanently blocked

See below screenshot:

Hostgator Banned WordPress Site

In this case, he had no choice & instead of upgrading his account to Optimized Hosting; he purchased WordPress hosting account from TrafficPlanetHosting.

This was my first-time experience with them & I’m quite surprised with the overall experience with the dashboard, customer support & everything else. I helped my friend migrate his WordPress blog from HostGator to Traffic Planet Hosting & I took advantage of their sFTP feature to upload downloaded WP-content folder.

Since most of the web-hosting offers sFTP, below mentioned command will help you save a lot of headaches when you need to move or upload files to your server.

Unix command to upload File to Server from Local using sFTP:

In my case, I’m using Terminal on my Mac OS to run all these commands. If you are on Windows, you can use Putty for the same.

Open terminal on Mac & type:
sftp -oPort=2222 [email protected]

You can find uName & I.P from your Traffic planet hosting dashboard.

You will be asked, “Are you sure you want to continue connecting (yes/no)?” Type Yes.

Type ls to list directory & use cd directoryname to change the working directory.

Here is a screenshot for better understanding:

LS CD Unix Command

You can anytime use command help to see all available commands.

The next few commands will show how to change your local directory & how you can upload any file or folder using put command.

Type lls to list local directory struture.

Type lcd directoryname to change local directory.

Type put-r directoryname to start uploading directory to your server. The file will be uploaded to your server working directory. In above example,we are already inside public_html directory. You can use mkdir command to create a directory. You can also use FileZilla or any other FTP tool to create a directory.

Put command Unix

Depending upon your file size & your internet speed, the files will be uploaded in few minutes or hour.

Another way:

Since the target for me was to migrate all my data from HostGator to TrafficPlanetHosting (TPH), I compressed the WP-content folder & uploaded single folder using put command. TPH offers Usermin; you can use it to expand compress archive. Due to security limitation, you can’t uncompress .tar file using sFTP command.

More commands here

If you are reading this guide while migrating your WordPress blog hosting, I hope this helped you. If you are reading it to learn something cool, do share it on Twitter & with your friends. It will help our blog to grow.

 

Subscribe

Contents

Harsh Agrawal

Harsh Agrawal

A blog scientist by mind and a passionate blogger by heart. Blogging on WordPress platform since 2008. Sharing his learning about WordPress hosting to help other bloggers & entrepreneurs make better decisions.

1 thought on “How To Upload Local File or directory on Server using sFTP”

  1. hey
    i read your article and I want to have a shared hosting server, with multiple domains and obviously different content on each.thanks to share with us this post

Leave a Comment

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

Share via
Copy link
Powered by Social Snap