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

允我心安 提交于 2019-11-28 21:03:17

问题


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

Im 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


回答1:


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.




回答2:


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

  • Go to your WinSCP profile

  • 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




回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/34798936/how-to-run-sudo-command-in-winscp-to-transfer-files-from-windows-to-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!