Browse All Articles
> How to transfer Files on a Webserver to local machine via SSH
We all know how boring and exhausting it is to transfer huge web projects developed locally to a webserver simply via FTP.
The File Transfer Protocol is a really nice solution if you need to transfer small amounts of files, but if you're planning to transfer your local development on your webserver via FTP it can take literally hours. For example a Joomla! installation package extracted on your local machine and transfered to the webdirectory where it's going to be installed takes more than ONE
hour via the open source FTP client called Filezilla
This is wasted time that you could have spent more productively going through the installation process, setting up a database connection for your project and have written your first articles in your blog or CMS.
There are several approaches to avoid long transfer time. I will go through one of them, where the good old FTP-client is still involved but where you will need an connection to your webserver via SSH (Secure Shell
), another very useful and encrypted network protocol.
What you need:
Filezilla or similar FTP client
Terminal App on a Mac or the comand line on a Windows System
In our common scenario you likely have a local webserver installed where you already have a development of your webproject and what you need to do now is to create a zip file of the folder where your webproject resides.
How to compress files really depends on your operation system. A google search with "create zip file of folder in *your platform*" will give you the answer. On a Mac do a ctrl-click and then click on "compress *your folder name*". On a Windows PC do a right click on your webprojects folder and goto "Send To->Compressed (zipped) folder".
In the next step you need to connect via your FTP Client Filezilla or similar and transfer the file to the directory on the webserver. I won't be going through the process of how to connect to your webserver via FTP since this article is about ssh and there are plenty of well explained tutorials on how to do that. This saves up tranfer time but you still will have to unzip the file on the webserver, which isn't possible via FTP.
This is where the Comand line Tool (Terminal for Mac or Putty for Windows) comes in handy. I will show the whole process on a Mac within the Terminal Application. Don't worry if you're on a windows PC, the commands are the same for a windows command line tool.
1. Open a Terminal or Putty Application
2. Type the SSH comand
Let me explain that a little more in depth. SSH tells the terminal to connect through that protocol. The protocol needs two pieces of information: the username on your webserver (It is the same you use to connect via FTP) and the ip-address of your webserver seperated by the @ symbol. Then press Enter on your keyboard.
3. The webserver will now be prompting for the password. Use the same as for your FTP connection. Don't worry if any character is shown after you've typed your password. This is a security feature of your terminal/command line application. It never shows passwords or dots as you may know it from a webform.
4. Now you are connected to your webserver and have more power over your files than you have with an FTP connection. First you want to browse to the directory where your zip file lies. This can be done by the cd (change directory) command.
5. You are now in the directory where your zip file lies, now there is only one little tiny line of code which extracts your files back out into the directory where it is lying right now.
This is all. Now you've extracted the zip file on your webserver. The whole process should have taken you not more than 15 minutes. No more waiting for FTP to transfer your files. The zip compression of your files saved you bandwith and transfer time. Extracting files on your server is an easy process as you could see. Good luck!