Using SCP instead of FTP

No comments on Using SCP instead of FTP

scp

I tried to delete a folder that contained tons of localization folders and waited for a very long time, since I was using FTP client and it was very slow during deleting and copying folders with massive amount of subfolders and files. That is why I decided to find another way to delete and copy files faster to the remote server from my local computer.

Secure copy or SCP is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. It is based on the Secure Shell (SSH) protocol.

SCP is more secure that plain FTP. It also allows to copy directly to the given folder on server, if permissions granted. FTP allows to copy only to the FTP folder.

AP_scp

These are the commands.

To copy files from server to your local machine:

scp -r root@lovecakes.ru:/root/www/ladby.ru .

To copy files from your local machine to the server:

scp wordpress-4.0.zip root@lovecakes.ru:/root/www/test.ladby.ru

To go to the folder with a folder, that will be copied (in my case it is common-app-server folder):

$ cd ~/Documents

To archive a folder, so that not to include Mac OS X system files like .DS_Store

~/Documents: $ zip common-app-server.zip common-app-server/ -x "*.DS_Store"

To remove a folder from server before copying a new version:

# rm -rf common-app-server

To copy zip file using SCP:

$ scp common-app-server.zip root@lovecakes.ru:/var/www/den.ladby.ru/public

Here root is a user name, that has permission to write to the destination folder.
lovecakes.ru – server name
/var/www/den.ladby.ru/public – destination folder

To install zip on server:

# sudo apt-get install unzip

To unzip copied folder on server:

# unzip common-app-server.zip -d

To remove MACOSX folder:

# rm -rf __MACOSX

To remove zip file on server and local machine after unzipping:

# rm common-app-server.zip

To copy a folder without archiving:

$ scp -r common-app-server root@lovecakes.ru:/var/www/den.ladby.ru/public

Comments

Leave a Reply

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