2018/08/27

How to use WinSCP to copy files / directories to directory that requires root privilege when root login has been disabled.

This post is about how to use WinSCP to copy files and/or directories to a Linux directory that requires root privilege but root login has been disabled for security reason.

Method - 1: Use WinSCP and Putty

1. Copy the files / directories from your computer to your home directory on a Linux machine using WinSCP first.


2. Launch a putty terminal, change working directory to where the copies files / directories are located. Use the command  sudo cp -a . /var/www/html to copy all the files / directories to the destination directory.


Method - 2: Configure WinSCP To Allow Access

Reference:

1. Launch WinSCP. Click on "Advanced..".


2. Click on SFTP, select "sudo su -c /usr/lib/sftp-server" from the list.

Note that the path "/usr/lib/sftp-server' might be different in your system**.


3. Click "OK" to save.

4. Enter the required info. then click on "Login" to connect. 


5. Now that the files / directories could be directly copied to previously restricted directory using WinSCP.

--------------------------------------------------------------------------------------------------------------------------

** For this post, the sftp-server of my system (DigitalOcean Droplet running Ubuntu 16.04) is located under "/usr/lib".


No comments:

Post a Comment