News for hackers. Stuff that matters.
Re:Unix tricks by mikegioia on Thursday March 07, 2013 @10:55AM (#5338286)
'ssh -R 12345:localhost:22 server.com "sleep 1000; exit"' forwards server.com's port 12345 to your local ssh port, even if you machine is not externally visible on the net.

This one blew my mind

Re:Unix tricks by malloc2x on Thursday March 07, 2013 @11:09AM (#5338362)
Better to use, e.g.:

  ssh -fN -o ServerAliveInterval="240" -R 2222:localhost:22 example.com
(And on example.com ssh -p 2222 localhost)

This lets you easily keep the tunnel open long-term. Why?

  -f    Background the ssh process (don't need nohup)
  -N    Don't run any command
  -o... Make ssh do the work of keeping the session alive forever
Re:Unix tricks by jackalope on Thursday March 07, 2013 @01:52PM (#5339386)
The ServerAliveInterval option might also help with another issue mentioned in the post:

'sshfs_mount' is not really stable, any network failure will be troublesome'

To avoid trouble with remote backups and other long running processes, I always add the following to the end of ~/.ssh/config or /etc/ssh_config:

    Host *
        ServerAliveInterval 300
Re:Unix tricks by carlesfe on Thursday March 07, 2013 @02:16PM (#5339534)
But the remote host can limit your ServerAliveInterval, however most hosts don't close your session if there is something running. On our clusters this is the only working solution, and I tried both, trust me.
Re:Unix tricks by malloc2x on Thursday March 07, 2013 @06:08PM (#5341007)
If that's an issue (I've never met a server like that, not to mention one like that and I couldn't change the setting) then wouldn't you rather use this?

  while [ true ]; do sleep 1000; done
Just using:

  sleep 1000; exit
means you can't make new connections after 17 minutes.
Re:Unix tricks by carlesfe on Thursday March 07, 2013 @06:44PM (#5341175)
Yes, in fact I use the first one (while true; sleep; ls) but I thought the second is more succint. Anyone interested can make a loop. Please notice that most of the snippets aren't meant to be copied & pasted, but rather analyzed and understood by the user.
Re:Unix tricks by malloc2x on Thursday March 07, 2013 @08:59PM (#5341698)
Ah, sometimes that's a hard line to draw since often the people that know enough to understand not to take it literally don't really need the pointer in the first place. :)

I enjoyed your list.

Re:Unix tricks by mikegioia on Thursday March 07, 2013 @05:26PM (#5340781)
This is excellent, thank you!
Re:Unix tricks by jonstjohn on Thursday March 07, 2013 @11:42AM (#5338560)
Thanks for calling that one out - had never tried that before and works great. Putting into my bag of tricks ...