Workaround for Putty and Vim



  • Man, I've never created so many threads in one week! Incredible.

    So here's my plight: there's this acquired customer of ours who has a site on a Linux server and I only have access with PuTTY, and I'm supposed to edit the files with Vim.

    Obviously, this sucks donkey ass. You can't work like that. It's like working on a console-based iPhone. I have nothing against Vim and its sado-masochistic learning curve, nor against console access with kewl commands, but it's a last-ditch effort to maintain website code; not a proper way to actually do productive work.

    Is there a way to slurp those files onto my local machine, where I can use high-falutin' new-fangled young'n things like multitasking, interactive folder trees, multiple open documents and software that I actually know how to use? And of course, a way to dump them back on the server when I'm done?

     

    I SURE HOPE SO.

    My next post is my 4200th post. Huzzah!


  • Discourse touched me in a no-no place

    @dhromed said:

    Is there a way to slurp those files onto my local machine, where I can use high-falutin' new-fangled young'n things like multitasking, interactive folder trees, multiple open documents and software that I actually know how to use? And of course, a way to dump them back on the server when I'm done?
    WinSCP? I'm assuming by your mention of PuTTY you're using ssh.



    Explorer/Midnight commander type interface. Double clicking a remote file silently copies to your local machine and opens it in your favourite editor. Saving the file (providing the connection doesn't get broken) automatically transfers the file back to the remote machine.



    That the sort of thing you're after?



  • @PJH said:

    WinSCP. Double clicking a remote file silently copies to your local machine and opens it in your favourite editor. Saving the file (providing the connection doesn't get broken) automatically transfers the file back to the remote machine.
     

    If it works as transparently as you say it does, then you are my all-time favourite person man in the world, and hey, PM me for my phone number so you can give me a call if you need my firstborn.



  • @dhromed said:

    Is there a way to slurp those files onto my local machine, where I can use high-falutin' new-fangled young'n things like multitasking, interactive folder trees, multiple open documents and software that I actually know how to use? And of course, a way to dump them back on the server when I'm done?
    Personally I use source control for that. SVN and git both can use SSH as the transport.



  • @Lingerance said:

    source control
     

    The server has no source control.

     

     

    WinSCP works like a bloody charm. It is awesome.

    Except...

    I'm not a unix weenie, and when I used Putty to browse around the site,  our Unix guy said I needed to use sudo bash to get access to the site's folder. But I apparently can't login with WinSCP as user root, andI don't see a command line entry thingy. I looked around the Help, and found that I might run the sftp server as root, but I can't find it on the server and thus can't tell WinSCP the path to run as root. I doubt sudo bash would work anyway, because it instantiates a new root subconsole from where I was at that point. There's no such equivalent in WinSCP, it seems.

     

    It looks like I'm still fucked.


  • Discourse touched me in a no-no place

    @dhromed said:

    I'm not a unix weenie, and when I used Putty to browse around the site,  our Unix guy said I needed to use sudo bash to get access to the site's folder.
    Ah. An apparent WTF at last.



    It would appear that the folder and descendants are owned by root.



    Have a look at this. If that doesn't help, can you change the group/owner of the files? Ideally to the user you're using to ssh in from.



  • @dhromed said:

    The server has no source control.
    Is it infeasible to ask for it? It'd be better if the server was the client, then you could just pull from your site (might need port redirection).
    @dhromed said:
    I'm not a unix weenie, and when I used Putty to browse around the site,  our Unix guy said I needed to use sudo bash to get access to the site's folder.
    You're going to have to somehow get write access for your user. g+w isn't super great, but if you can get your user added to the www-data/http/whatever group you should be set, an ACL would be preferable.



    Note: these are separate solutions.



  • Tell your Unix guy to give you and the directory sane permissions.  Either have him chown the directory into a meaningful group and add you to that group, or have him add you to the group to which it already belongs.  Then chmod it g+rwx.  Requiring root access to browse directories required for work is a bit of a red flag.

    Edit: aw man, I got scooped!  I should proofread my posts less and just hit submit as fast as possible.



  • @PJH said:

    Have a look at this.
     

    That's the Help page I referred to earlier.

    I can't make any changes to the server, and I don't really want to when the Guy is on vacation and unable to shout at me for fucking the server.

     

    Hm..

     

    chown -R myloginuser mywebsitefolder should be fairly safe, right?

    Actually forget about that last line -- I don't even kow who owns the server or whether we actually admin it or whether our unix guy has any real authority over it. I'm not going to hacknslash my way through that bramble bush.

     

     

    Goddamnit.



  • @dhromed said:

    chown -R myloginuser mywebsitefolder should be fairly safe, right?
     

    I wouldn't recommend that, some webservers require the site directory to be owned by www or another known www entity.  For example I have a couple PHP sites I admin (TRWTF) that write caching information into their pwd.  Since the PHP is running as www, if the directory was owned by me and not world-writable, then the site would probably start spewing out error messages and/or die.



  • What is the directory structure of the site..?   Could you ssh in as www instead of root..?



  • @Lingerance said:

    Is it infeasible to ask for it?
     

    Yup.

     

    What is the directory structure of the site..?   Could you ssh in as www instead of root..?

    My user is admin.



  • @dhromed said:

    My user is admin.
    D: Shared logins are fail.
    @dhromed said:
    @Lingerance said:
    Is it infeasible to ask for [source control]?
    Yup.
    Is it possible to make it so you pull the code changes from your site instead of pushing them? You should be able to use port redirection, you only need to have an internal system you can locally sync with, then just have a putty session that logs in, makes the tunnel, runs the pull script and ends the session. That way pushing live is only a single click.



  • @Lingerance said:

    Is it possible to...
     

    Your words make little sense to me and I have no idea how what port redirection means or incorporate it into my process.

    In any case, I don't have any real control over this system. It's just me, a putty console and a stupid server with an interestingly structured php site.

    You do suggest there is a way to slurp the files through putty. I want to slurp the files so bad. Please elaborate.



  • @Lingerance said:

    pushing live
     

    I think his current problem is getting all current files in a sane way.

    @dhromed: you could probably write some script yourself. I think there are Perl modules to do this (other languages no doubt have it too but Perl happens to be my Swiss Army Chainsaw) and with a bit of luck you could frozzle some example script into sth useful.

     



  • Generally speaking, you mean a [perl] script that runs on my windows machine that initates an SSH connection as root and slurps the files to a folder of my liking?

    I am apparently unable to login directly as root. From what I gather, this is a server setting, and I have no control over that.

     

    If only I had some mini nukes. :(



  • Instead of syncing them locally, you could always sudo in as root, copy your files to ~ on the server, then play around with them in an unprivileged mode via WinSCP or whatever.  When you're finished, sudo back in as root and copy them back.

    Scripts could make this easier, of course.   Whichever way you want to sync it, the goal is to get the privileged files into an area where you can modify them as yourself.



  • @dhromed said:

    Your words make little sense to me and I have no idea how what port redirection means or incorporate it into my process.
    SSH is capable of doing two forms of port tunneling. One makes a listening port on the SSH client which will forward any connections through the connection to whatever you define on the other side (so long as the server machine can reach it), you do NOT want this one for what I proposed. The other works the other way, the server machine gets the listening port which gets forwarded to something the client can see.



    So, make Server C (your client) listen on port 1111 (must be anything over 1024) which will get forwarded to Server A (a server on your side) port X (a port which runs the service you want to forward, we'll say SFTP, because that's easy to forward, SMB might be easy to forward in this setup too, I make no promises). There is a lovely GUI in putty to set this all up for you.



    Now you write a simple script (think batch file) that will pull all of the changes from Server A to a local directory on Server C, the script gets run on Server C. The sudo cp -R drop/www/ /var/www/ (replace drop/www/ with where you're dumping the files and /var/www/ with their final destination).



    Once the script works configure a special host in putty that A) sets up tunnel B) logs in C) runs the script (IIRC it can do this).



    Pat yourself on the back, you can now push the code live from a server on your local network with a single click.



  • @dhromed said:

    I have no idea how what port redirection means or incorporate it into my process.
    That's easy.  You insert the small end first, going slowly, and firmly but gently push it into your process.  It helps if you're drunk.



  • @dhromed said:

    You do suggest there is a way to slurp the files through putty. I want to slurp the files so bad. Please elaborate.

    If all else fails, there are a couple of things you can do ... 
    
    If you have cygwin, you can execute a remote command to make an archive and send it back to you.
    
    $ ssh admin@lame.site "sudo tar cvf - /var/www | bzip2" > site.tar.bz2
    
    If all else fails, you can do something like this on the remote:
    
    $ sudo tar czvf site.tar.gz /var/www
    * turn on logging in putty *
    $ xxd site.tar.gz 
    * lots of lines of gunk *
    
    Now run the hex part of the log through xxd -r on your windows box (xxd from here http://www.wzw.tum.de/~syring/win32/UnxUtilsDist.html)
    

    Sorry about the < pre > but I'm too lame to learn bbcode and the wysiwyg editor didn't appear :-(



  •  guy is back.

     He tar that shit.

    I slurp it with WinSCP.

    I am much happier now.

    Thank you all for the kind aid!



  • @bstorer said:

    That's easy.  You insert the small end first, going slowly, and firmly but gently push it into your process.  It helps if you're drunk.
     

    *shiver*



  • @Lingerance said:

    SMB might be easy to forward in this setup too, I make no promises).
      Yeah, that one is easy. Not. You need to install a patch, add a new hardware adapter, configure it to have a bogus IP address, turn on some tweaks in the adapter, forward 5 ports to the faked address and restart your computer. And then you are lucky if it works. What a joke! (see http://www.blisstonia.com/eolson/notes/smboverssh.php ). I did this for a customer whose provider blocked the SMB traffic for some reason ( Dutchland btw, Ziggo, such a crap provider).



  • Epilogue: I got the guy to chown the folder to admin instead of root, and ironically, the second issues I was tasked to fix (for which I need reasonable debugging abilities i.e. one-file-at-a-time upload), was not an issue at all, but data corruption.


  • Notification Spam Recipient

    @dhromed said in Workaround for Putty and Vim:

    Man, I've never created so many threads in one week! Incredible.

    You should really try for another record breaker!

    @dhromed said in Workaround for Putty and Vim:

    hey, PM me for my phone number so you can give me a call if you need my firstborn.

    Did you ever follow through on that, btw?

    @dhromed said in Workaround for Putty and Vim:

    our Unix guy said I needed to use sudo bash to get access to the site's folder

    Your unix guy was apparently an idiot. He should have had you generate a private key and added the public key to the authorized_keys file for root. If that was even necessary, it probably shouldn't have been for web stuff...

    @Xyro said in Workaround for Putty and Vim:

    Requiring root access to browse directories required for work is a bit of a red flag.

    👍

    @dhromed said in Workaround for Putty and Vim:

    Your words make little sense to me and I have no idea how what port redirection means or incorporate it into my process.

    Yeah, not sure what that guy was on about...

    @b_redeker1 said in Workaround for Putty and Vim:

    you could probably write some script yourself. I think there are Perl modules to do this (other languages no doubt have it too but Perl happens to be my Swiss Army Chainsaw) and with a bit of luck you could frozzle some example script into sth useful.

    wat.

    @dhromed said in Workaround for Putty and Vim:

    I am apparently unable to login directly as root.

    @Lingerance said in Workaround for Putty and Vim:

    port tunneling.

    This whole idea seems besides the point, actually...

    @arty said in Workaround for Putty and Vim:

    Sorry about the < pre > but I'm too lame to learn bbcode and the wysiwyg editor didn't appear

    It didn't get much better over the years!

    @Obfuscator said in Workaround for Putty and Vim:

    I did this for a customer whose provider blocked the SMB traffic for some reason

    Yeah, ya really should have just stuck with scp...


  • Fake News

    @Tsaukpaetra Awww, you made me sad and long for the time when @dhromed was still around... :(



  • @JBert said in Workaround for Putty and Vim:

    @Tsaukpaetra Awww, you made me sad and long for the time when @dhromed was still around... :(

    Found him:


  • Notification Spam Recipient

    @JBert said in Workaround for Putty and Vim:

    @Tsaukpaetra Awww, you made me sad and long for the time when @dhromed was still around... :(

    Well, it's better to remember and reminisce, than to forget and... um... what are we talking about now?


  • I survived the hour long Uno hand

    @dhromed said in Workaround for Putty and Vim:

    Is there a way to slurp those files onto my local machine

    Moba X Term has a feature where you can open the files locally and it'll SCP hem back when you save. It's a lot nicer to use than PuTTY, I've found.



  • @Yamikuronue said in Workaround for Putty and Vim:

    Moba X Term

    [Dota 2 logo having sex with command prompt logo]



  • @Tsaukpaetra said in Workaround for Putty and Vim:

    @Obfuscator said in Workaround for Putty and Vim:

    I did this for a customer whose provider blocked the SMB traffic for some reason

    Yeah, ya really should have just stuck with scp...

    SCP Foundation ???


  • Trolleybus Mechanic

    I'd use sshfs (with fuse), it lets you mount a remote directory as a normal block device through ssh. If the server is a normal linux (not some 4MB-flash openwrt/dropbear) with openssh, this will work.



  • One of the better ad-hoc setups I made was an rsync running in an endless loop. Edit files in a proper GUI editor, see live changes directly on the server.


  • Notification Spam Recipient

    @sebastian.galczynski said in Workaround for Putty and Vim:

    not some 4MB-flash openwrt/dropbear

    That's... surprisingly specific. I'm assuming you've attempted this on your router then?


  • Trolleybus Mechanic

    @Tsaukpaetra Yep, I needed to transfer something from/to the router, so I reflexively typed ssh://root@192... in the file manager bar. Didn't work with dropbear. But @cartman82 's rsync would work, since it only relies on piping data through shell.


  • Notification Spam Recipient

    @sebastian.galczynski said in Workaround for Putty and Vim:

    typed ssh://root@192... in the file manager bar.

    0_1496732717560_ad34366f-f789-4c60-8ab3-c92c3f06a10b-image.png

    Well, I guess DD-WRT isn't using dropbear then... :P



  • @Tsaukpaetra said in Workaround for Putty and Vim:

    @sebastian.galczynski said in Workaround for Putty and Vim:

    typed ssh://root@192... in the file manager bar.

    0_1496732717560_ad34366f-f789-4c60-8ab3-c92c3f06a10b-image.png

    Well, I guess DD-WRT isn't using dropbear then... :P

    What's with the octal representation of the second 0x01 octet?


  • Notification Spam Recipient

    @ben_lubar said in Workaround for Putty and Vim:

    @Tsaukpaetra said in Workaround for Putty and Vim:

    @sebastian.galczynski said in Workaround for Putty and Vim:

    typed ssh://root@192... in the file manager bar.

    0_1496732717560_ad34366f-f789-4c60-8ab3-c92c3f06a10b-image.png

    Well, I guess DD-WRT isn't using dropbear then... :P

    What's with the octal representation of the second 0x01 octet?

    ...? Huh?

    Edit: Oh, it did weird for some reason. Had to have something change, otherwise it would automatically fail with some error.


Log in to reply