I've searched around the net a bit and couldn't find something that would help in my case. I have a query where I access a linux server with my username and password. Once I login I need to sudo to another user with higher privileges in order to access/edit certain files. I can use EditPlus in windows to open up and edit any files on the linux server that are owned by my username. I can't do the same for the files that are owned by the sudo user (is that the right wording?). Is there any way I can use an editor in windows that will let me get to the files that aren't owned by me but I do have access to them once I sudo to the appropriate superuser?
Any help is appreciated?
I assume you are accessing a shared folder from windows? I'd assume the permissions on the samba(for example) server would need to be changed independently for you to get access.
Or maybe you could copy them to a location you have access(and modify ownership if necessary) to using the terminal edit them and copy them back?
PS, definitely not an expert and not completely confident I'm interpreting your question correctly.
Setup the higher privilege user on your PC with the same password.
Then start the windows editor as that user. You'll need to map the drives for that user too.
If you need to edit these files often perhaps they have the wrong permissions to begin with? If so just change the permission or perhaps just the owner of them to be your login. What kind of files are you editing and for what purpose?
Might be misunderstanding your requirements, but can you not just use a Windows based client like putty to SSH into the Linux machine and use your Linux text editor of choice (and sudo if/when necessary)? WinSCP is better at this (in terms of a GUI), but I only use putty and vi.
I connect to the linux servers from Windows using putty. I can use vi to edit whatever files I want, but I'm not a fan of using it, I much prefer to use winscp and then edit the files in EditPlus. That's what I currently do for files that my username owns. The problem is that some of the files can only be edited by a superuser. I have sudo rights to get to that superuser. So I log into the linux box with putty sudo over to the user with my privileges (sudo su - superusr) and then I can edit whatever I want using vi. I can't do this with WinSCP. I can connect to the box with WinSCP as my username, but I can't run any sudo commands or anything to get to the files owned by superusr.
Does this make sense what I'm saying? I'd like to be able to edit files using EditPlus, as I currently do for some that I own on the server, but I can't do it for the ones owned by a super user, even though my login does allow me to sudo over to that superuser. Changing permissions or how this is setup is not an option, this is how the company have configured their security. I don't think there's any way I can do what I want to do, but I hope I'm wrong.
backwards way to do it I'm sure but I'd imagine this should work
in putty -
sudo cat filetobeedited > tmpfile
(tmpfile shouldn't have any restricted permissions)
then pop into winscp and edit away
sudo cat tmpfile > filetobededited
once again - in my head that will work but I'm sure there's a much better way of doing it
In WinSCP, you can set "sudo su -" as your login shell. It's even a built in option. Make sure advanced options is checked, go to Environment -> SCP/Shell and set your shell to that.
Thanks for the assistance everybody.
Just to follow up on this I tried tehjimmeh suggestion of putting in my sudo su command into the Advanced options, but it didn't work. I tried Filezilla to do this as well, but I couldn't get it to work either. I saw the following enhancement request for FileZilla:
This got rejected by FileZilla:
So I guess I can't do what I was hoping to do.
I would increase your security risk ... but you could just set a password for root, enable root logins via ssh then login in via it from windows!
I wouldn't be a route (pun intended ) I'd take but it is posible.
If you ssh in via putty, you are giving yourself an awful lot of work downloading the file to windows, and then editing it, and then pushing it back to the server. Vi/Vim is hard at first, but there are tutorials that will give you the basics. I'm using Vi for over 10 years and I really only use the basics, (insert, replace, find, top of page, end of page, newline, and a little reg ex). Learn those and you should have enough to work. Alternatively try nano, its a very straight forward editor.
I know this isnt the advice you want, but Linux isnt going away, and twenty minutes familiarising your self with either Vi/vim or Nano, will save you hours in the long run.
Plus, copying files from a server to a windows client and then putting them back may violate privacy/security policies in future contracts, if it does not already. Just something to be wary of.
Since you have root access I'd suggest either adding yourself to the group that owns the files or creating a new group for the purpose. I assume then you could use winscp.
One means (though depending on the environment in which you are doing it it may not be advisable) would be to make a note of the current permissions on the file you want to edit, chmod 777 it as the sudo user on ssh, edit it via winscp, save, and restore the permissions as the sudo user on ssh.
It is roundabout, and if they were config files in a production system I would avoid it for fear of not restoring permissions correctly, but it's a workaround nonetheless