A Web.com Partner

Retaining Directory Permissions While Using SCP

SCP is a secure file transfer protocol that is used in Linux. SCP is similar to FTP that it allows you to connect to a remote server and transmit your files via the connection. However there is one thing that SCP will allow you to do that FTP will not let you and that’s the ability to retain the original directory permissions when in transport. This article will briefly explain how to do this. terminal-icon-200x200

    1. Log into your Linux server via SSH / Shell
    2. Locate the file or directory that you are waiting to transfer.
    3. Now you will connect to the remote server will you normally would using SCP, however now you will at a new attribure to the connection command. An example would be if you wanted to transfer a directory while keeping the permissions you would type the following;
      “scp -rp –preserve /your_directory_path root@remote_server:/directory”
    4. The addition of the “-p” attribute allows you to retain permissions while in transfer while the “-r” tells the system to recurisvely copy the entire contents of the directory.
    5. Using this command will allow you to transfer files quickly without the issue or worrying about reapplying permissions on the directories.