Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run SUDO command in WinSCP to transfer files from Windows to linux

Tags:

linux

sudo

winscp

I am trying to use WinSCP to transfer files over to a Linux Instance from Windows.

I'm using private key for my instance to login to Amazon instance using ec2-user. However ec2-user does not have access to write to the Linux instance

How do I sudo su - to access the root directory and write to the linux box, using WinSCP or any other file transfer method?

Thanks

like image 368
PC2015 Avatar asked Jan 14 '16 20:01

PC2015


People also ask

Can we use sudo in WinSCP?

Note that as WinSCP cannot implement terminal emulation, you need to have sudoers option requiretty turned off (which is default).


4 Answers

I know this is old, but it is actually very possible.

  • Go to your WinSCP profile (Session > Sites > Site Manager)

  • Click on Edit > Advanced... > Environment > SFTP

  • Insert sudo su -c /usr/lib/sftp-server in "SFTP Server" (note this path might be different in your system)

  • Save and connect

Source

AWS Ubuntu 18.04: enter image description here

like image 57
Pelly Avatar answered Oct 16 '22 08:10

Pelly


There is an option in WinSCP that does exactly what you are looking for:

enter image description here

enter image description here

like image 45
Eng.Fouad Avatar answered Oct 16 '22 09:10

Eng.Fouad


AFAIK you can't do that.
What I did at my place of work, is transfer the files to your home (~) folder (or really any folder that you have full permissions in, i.e chmod 777 or variants) via WinSCP, and then SSH to to your linux machine and sudo from there to your destination folder.

Another solution would be to change permissions of the directories you are planning on uploading the files to, so your user (which is without sudo privileges) could write to those dirs.

I would also read about WinSCP Remote Commands for further detail.

like image 41
Idos Avatar answered Oct 16 '22 10:10

Idos


Usually all users will have write access to /tmp. Place the file to /tmp and then login to putty , then you can sudo and copy the file.

like image 4
S A Avatar answered Oct 16 '22 08:10

S A