Linux text editor in Windows - boards.ie
Boards.ie uses cookies. By continuing to browse this site you are agreeing to our use of cookies. Click here to find out more x
Post Reply  
 
Thread Tools Search this Thread
23-03-2012, 16:46   #1
gerbear1
Registered User
 
Join Date: Jan 2010
Location: Dublin
Posts: 135
Linux text editor in Windows

Hi guys,

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?
gerbear1 is offline  
Advertisement
23-03-2012, 17:08   #2
humbert
Registered User
 
humbert's Avatar
 
Join Date: Sep 2005
Posts: 5,073
Send a message via Skype™ to humbert
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?

Alternatively, vim?

PS, definitely not an expert and not completely confident I'm interpreting your question correctly.
humbert is offline  
Thanks from:
23-03-2012, 17:15   #3
ronkmonster
Registered User
 
Join Date: Dec 2008
Location: North Dublin
Posts: 1,148
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.
ronkmonster is offline  
23-03-2012, 17:30   #4
croo
Moderator
 
Join Date: Aug 2006
Location: Westmeath
Posts: 1,116
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?
croo is offline  
23-03-2012, 18:17   #5
druidhill
Registered User
 
Join Date: Aug 2008
Posts: 162
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.

Last edited by druidhill; 23-03-2012 at 18:31.
druidhill is offline  
Advertisement
24-03-2012, 17:06   #6
gerbear1
Registered User
 
Join Date: Jan 2010
Location: Dublin
Posts: 135
Quote:
Originally Posted by druidhill View Post
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.
Thanks for the replies everybody. I didn't explain myself very well, I wrote the post kinda in a rush. This is close to what I'm looking for.

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.
gerbear1 is offline  
25-03-2012, 02:15   #7
johnmcdnl
Registered User
 
johnmcdnl's Avatar
 
Join Date: Oct 2009
Posts: 3,342
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

and
sudo cat tmpfile > filetobededited
rm tmpfile


once again - in my head that will work but I'm sure there's a much better way of doing it
johnmcdnl is offline  
25-03-2012, 02:31   #8
tehjimmeh
Registered User
 
Join Date: Sep 2010
Posts: 88
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.
tehjimmeh is offline  
Thanks from:
25-03-2012, 20:08   #9
gerbear1
Registered User
 
Join Date: Jan 2010
Location: Dublin
Posts: 135
Quote:
Originally Posted by tehjimmeh View Post
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.
This seems very promising to what I want to do. I'll try it out in work tomorrow and report back.

Thanks for the assistance everybody.
gerbear1 is offline  
Advertisement
27-03-2012, 11:24   #10
gerbear1
Registered User
 
Join Date: Jan 2010
Location: Dublin
Posts: 135
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:

http://trac.filezilla-project.org/ticket/2215

Quote:
Hi,
when root login is disabled in the remote ssh server
sshd_config (PermitRootLogin no) you need the "su"
command to get access to folders which need root
privileges. As you can't login as root, you can't d/l with
the "download as" dialog for obvious reasons.
Please implement an "su" (substitute user) dialog.
Thanks for this great program
michaah
This got rejected by FileZilla:

Quote:
SFTP does not support this command.
So I guess I can't do what I was hoping to do.
gerbear1 is offline  
27-03-2012, 18:39   #11
croo
Moderator
 
Join Date: Aug 2006
Location: Westmeath
Posts: 1,116
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.
croo is offline  
28-03-2012, 09:18   #12
syklops
Registered User
 
Join Date: Sep 2004
Location: Dublin, Ireland
Posts: 16,427
Quote:
Originally Posted by gerbear1 View Post
Thanks for the replies everybody. I didn't explain myself very well, I wrote the post kinda in a rush. This is close to what I'm looking for.

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.
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.
syklops is offline  
Thanks from:
28-03-2012, 21:42   #13
humbert
Registered User
 
humbert's Avatar
 
Join Date: Sep 2005
Posts: 5,073
Send a message via Skype™ to humbert
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.
humbert is offline  
Thanks from:
05-04-2012, 22:55   #14
cython
Registered User
 
cython's Avatar
 
Join Date: Sep 2005
Location: Dublin 15
Posts: 1,701
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
cython is offline  
Post Reply

Quick Reply
Message:
Remove Text Formatting
Bold
Italic
Underline

Insert Image
Wrap [QUOTE] tags around selected text
 
Decrease Size
Increase Size
Please sign up or log in to join the discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Share Tweet