Problem specification
When I am working on a project, the Permission Denied prompt will appear when I upload a file to the Linux server using WinSCP, with an error return code of 3. The error figure is as follows:
As you can see from the above error, the file upload failed because of insufficient permissions, because we connected to the server as a normal user, so the solution is to connect to the server as root user, so you have the right to upload files, so how to connect to the server as root user?Let’s take a look!
The solution
1. Check the path of SFTP service on your server
On the server using the command: cat/etc/SSH/sshd_config | grep SFTP
my server output: Subsystem SFTP/usr/libexec/openssh/SFTP server. –
2. Set the connection in winSCP
Set up your host name, port, user name and password. If you log in with a key instead of a password, you do not need to fill in the password. Then click Advanced and click SFTP, and the following interface will appear:
Pictured above Settings SFTP, only need to fill in the SFTP server with sudo/usr/libexec/openssh/SFTP server, sudo the back of the class capacity is the first step we by running the cat/etc/SSH/sshd_config | grep SFTP SFTP service path. After filling in the SFTP server, click shell and the following interface appears:
As shown in the figure above, you can set the shell by filling in sudo-I in the shell. If you are using the key to log in, then you need to click the verification under SSH, and the following interface appears:
Then select the key file. Click OK, click log in and connect to the server. At this point, we connect to the server as root. At this point, we can upload files normally.