Editing with Winscp

I would like to edit files in my /etc from winscp.

I have administrator privileges on this computer, How can i edit files and save them from Winscp in folders that require sudo be written before any modifying changes.

I would like to do this because I hate editing files in the terminal on a windows machine, and Winscp provides a nice editor which is often way more conv

Please and thank you.


How can I edit files and save them from Winscp in folders that require sudo be written before any modifying changes.

Given this requirement, that you are logged in as an unprivileged users with sudo access, there is no direct way to do this with winscp connection.

What you could do is enable SSH access to root with a key and then setup key-based authentication. To accomplish this you would set PermitRootLogin without-password in your /etc/ssh/sshd_config, and then you would generate a key using your favorite tool (maybe puttygen.exe), and place the public component in /root/.ssh/authorized_keys. If you will search this site you will find lots of questions and answers about key-based authentication. Then simply use winscp to connect as the root account and you will have the ability to edit things as required.

I will caution you that if you do this, it is extremely important that you use a text editor that will create text files using UNIX-style line endings. Something like notepad, or wordpad will seriously screw up your configuration files.

You should also not even consider doing this until you have a system in place to back things up, just in case something does get screwed up.

Also, I would suggest you use something like etckeeper so your /etc directory is stored in a version control system. This will allow you to quickly go back to previous versions if you use it properly.

Another method would may be better and still give you a GUI text editor would be to install a X11 server on windows, and a GUI editor on the server like SciTE. Then you would SSH with X11 forwarding enabled, and you could start the GUI text editor, and edit the files. (My answer from a similar question can be found here https://superuser.com/questions/134688/putty-external-text-editor/134694#134694)


While I would HIGHLY discourage editing system files in this manner (you should really log in using an ssh client such as putty then edit the files using vim, emacs, joe, nano, etc.), it does appear to be possible:

http://winscp.net/eng/docs/faq_su

For some files such as /etc/sudoers, /etc/passwd, and /etc/shadow, you should really be using commands like visudo and vipw instead of editing the files directly. Editing these files using an editor launched via WinSCP skips some of the safeguards these commands provide.

But, really, don't do it. Not for system files.


Cakemox is correct. However, using ssh connection to change system files is way to go. You can use putty to connect your ssh server.

I am using WinSCP for file transfer, and Putty for remote connection.