Live data from Hacker News

SSH Examples, Tips and Tunnels

hackertarget.com

41–50 of 72 posts

Re: SSH Examples, Tips and Tunnels

#41
post #27

Earlier quoted context omitted.

The obvious case would be when the remote grep doesn't exist at all, or is a cutdown non-gnu version of grep which didn't support things like extended or perl regexps

What chance is there that grep doesn't exist on a machine that has ssh and cat? Having some undesired grep version could be one reason but not enough to justify piping everything before grep in the example.

There are systems with SSH that are not Unix. For instance, Cisco switches support SSH but don't have a grep. (They do have an equivalent, but it's unfamiliar and likely less feature-rich)

Re: SSH Examples, Tips and Tunnels

#42

If you liked this article, PLEASE, PLEASE just take 10 minutes to look at the manpages for ssh(1) and ssh_config(5). SSH options are nothing we need to research about, we humans made it and we wrote documentation for it. The manpages are also exhaustive, definitive, and valid for the exact version you have installed. Please, instead of making more 'how to use SSH'-articles popular, read the manpages yourself. Reading…

My usage of manpages would increase by orders of magnitude if I knew there were examples of actual working commands in the first page. Most of the time I am not looking for an obscure parameter, but my brain just has failed to take a note of the basic syntax of the command. So why not start ssh manpage with two simple examples, how to connect to a host with username and ssh key: ssh user@example.com ssh -i ~/.ssh/id_…

That is the reason why I like the Golang documentation; it consists of exhaustive comments, (runnable) examples, explanatory code snippets and links to the corresponding source.

Works as a reference but also for explorative learning.

Re: SSH Examples, Tips and Tunnels

#43

Is there a way to combine screen/tmux with ssh ? like i always need to do some long running tasks over ssh and forget to put it in a screen session, i would like to open each ssh session in a screen session so that when i connect next i should be able to proceed from where i left

You can indeed reattach a session into screen/tmux:) https://github.com/nelhage/reptyr

Also consider using ssh config to make your default command create or attach a tmux session.

Re: SSH Examples, Tips and Tunnels

#44

I've been using SSH tunnels for years, this keeps me safe and sane. Also at work where my employer closed almost everything. Including well known web pages with info useful for my work...

I would think twice before violating policy like that. YMMV, of course.

Re: SSH Examples, Tips and Tunnels

#45

Earlier quoted context omitted.

My usage of manpages would increase by orders of magnitude if I knew there were examples of actual working commands in the first page. Most of the time I am not looking for an obscure parameter, but my brain just has failed to take a note of the basic syntax of the command. So why not start ssh manpage with two simple examples, how to connect to a host with username and ssh key: ssh user@example.com ssh -i ~/.ssh/id_…

indeed. I've always thought this, would be nice to see examples that might cover my need. Then read what the switches/options do.

So you're just going to run some command without knowing what it does, just because it looks right?

Re: SSH Examples, Tips and Tunnels

#46
post #28

Does anyone use OSSEC on their personal workstation or personal server? I have some MacOS machines with public IP addresses with ssh access enabled, and I'm wondering if I should use something like this. Presently I have the MacOS firewall configured but that's it.

It's not needed, IMO, if you disable password auth and only allow ssh from white listed IPs. This has eliminated ssh login attempts for me.

Re: SSH Examples, Tips and Tunnels

#47

If you liked this article, PLEASE, PLEASE just take 10 minutes to look at the manpages for ssh(1) and ssh_config(5). SSH options are nothing we need to research about, we humans made it and we wrote documentation for it. The manpages are also exhaustive, definitive, and valid for the exact version you have installed. Please, instead of making more 'how to use SSH'-articles popular, read the manpages yourself. Reading…

My usage of manpages would increase by orders of magnitude if I knew there were examples of actual working commands in the first page. Most of the time I am not looking for an obscure parameter, but my brain just has failed to take a note of the basic syntax of the command. So why not start ssh manpage with two simple examples, how to connect to a host with username and ssh key: ssh user@example.com ssh -i ~/.ssh/id_…

There are a few projects out there trying to do this as community driven efforts or by extracting examples automatically from the existing man pages (or a mix of the two).

https://tldr.sh/ and http://bropages.org/ spring to mind, and I know there are others that I'm not immediately remembering ATM, both of which have web interfaces or can be installed as local command-line tools.

Re: SSH Examples, Tips and Tunnels

#48
post #31

Earlier quoted context omitted.

While I myself am not a purist, some people would consider this an instance of UUOC: http://porkmail.org/era/unix/award.html > localhost:~$ ssh remoteserver "grep badstuff.php /var/log/nginx/access.log"

The only reason I (and probably many other people) prefer cat | grep instead of just using grep is because it is much easier to change the search term this way. With cat, it’s only a ctrl-W away from using a different term. If I only used grep, i would have to move my cursor which can get pretty annoying with a long file path. That being said, only using grep is my preferred approach (if I don’t forget it) in script…

$ grep term1

$ ^term1^term2^

Try it

Re: SSH Examples, Tips and Tunnels

#49

Is there a way to combine screen/tmux with ssh ? like i always need to do some long running tasks over ssh and forget to put it in a screen session, i would like to open each ssh session in a screen session so that when i connect next i should be able to proceed from where i left

Yes, but this has nothing to do with SSH. You essentially suspend the process, background it, detach it from the parent shell, launch screen/tmux, and re-parent it. Here's a tutorial - http://monkeypatch.me/blog/move-a-running-process-to-a-new-s.... If you ALWAYS want SSH to open in a screen/tmux session, you can probably just alias it on your local system to do so.

Re: SSH Examples, Tips and Tunnels

#50

If you liked this article, PLEASE, PLEASE just take 10 minutes to look at the manpages for ssh(1) and ssh_config(5). SSH options are nothing we need to research about, we humans made it and we wrote documentation for it. The manpages are also exhaustive, definitive, and valid for the exact version you have installed. Please, instead of making more 'how to use SSH'-articles popular, read the manpages yourself. Reading…

Man pages can be great and people should always read them first. That said, I find that man pages often lack a wide sample of configuration examples, implementation examples and useful tips. This is where blogs and vlogs fill in the gaps. Man pages often leave many things to interpretation that varies wildly from person to person. Man pages sometimes also leave out best practices and caveats.
Post reply on HN