Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Linux text editor in Windows

  • 23-03-2012 4:46pm
    #1
    Registered Users Posts: 152 ✭✭


    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?


Comments

  • Registered Users Posts: 5,238 ✭✭✭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.


  • Registered Users Posts: 1,181 ✭✭✭ronkmonster


    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.


  • Moderators, Technology & Internet Moderators Posts: 1,332 Mod ✭✭✭✭croo


    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?


  • Registered Users Posts: 200 ✭✭druidhill


    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.


  • Registered Users Posts: 152 ✭✭gerbear1


    druidhill wrote: »
    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.


  • Advertisement
  • Registered Users Posts: 3,739 ✭✭✭johnmcdnl


    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


  • Registered Users Posts: 89 ✭✭tehjimmeh


    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.


  • Registered Users Posts: 152 ✭✭gerbear1


    tehjimmeh wrote: »
    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.


  • Registered Users Posts: 152 ✭✭gerbear1


    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
    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:
    SFTP does not support this command.

    So I guess I can't do what I was hoping to do.


  • Moderators, Technology & Internet Moderators Posts: 1,332 Mod ✭✭✭✭croo


    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.


  • Advertisement
  • Closed Accounts Posts: 18,969 ✭✭✭✭syklops


    gerbear1 wrote: »
    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.


  • Registered Users Posts: 5,238 ✭✭✭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.


  • Registered Users Posts: 4,757 ✭✭✭cython


    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


Advertisement