Live data from Hacker News

SSH Examples, Tips and Tunnels

hackertarget.com

21–30 of 72 posts

Re: SSH Examples, Tips and Tunnels

#21
post #10

Is the first "Using a Configuration File" example a bit misleading? The example is: ... Host remoteserver HostName remoteserver.thematrix.io User neo Port 2112 IdentityFile /home/test/.ssh/remoteserver.pub IdentityFile typically (always?) specifies a file with a private key, right?

Also it's suggested to use ~/.ssh/key to specify a key in your home folder to be a portable config and don't really need to show others what your user name is if it gets shared.

Re: SSH Examples, Tips and Tunnels

#22
post #13

Great article! One minor comment though, `folder` sounds so wrong in *nix world, I'd suggest you use directory instead.

Not the author but I find it easier to type folder than directory on qwerty. Not sure about other layout.

Re: SSH Examples, Tips and Tunnels

#23

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

This has nothing to do with ssh. That's already shell configuration topic. You can check for a possible solution here:

https://wiki.archlinux.org/index.php/Tmux#Start_tmux_on_ever...

https://superuser.com/questions/224631/is-it-a-good-idea-to-...

Re: SSH Examples, Tips and Tunnels

#24
post #10

Is the first "Using a Configuration File" example a bit misleading? The example is: ... Host remoteserver HostName remoteserver.thematrix.io User neo Port 2112 IdentityFile /home/test/.ssh/remoteserver.pub IdentityFile typically (always?) specifies a file with a private key, right?

Unless you're using something like a smart card as identity with gpg-agent, then you won't have a private key file. Because of that, you can specify a public key file to identify this private key.

Re: SSH Examples, Tips and Tunnels

#25
post #19
post #6

Earlier quoted context omitted.

The article does touch on that optimization: In this example the grep is being performed on the local system after the log file has been pushed across the ssh session. If the file is large it would be more efficient to run the grep on the remote side simply by enclosing the pipe and grep in the double quotes.

I see no benefit of running grep locally in any case unless maybe local grep is aliased in a complex way to colorize and decorate the outputs in some other way. Either way this is not a great example as you should just login and run it on the remote machine as running through pipe causes the connection to be established every time unless you keep a persistent connection open behind which is explained in the MultiPlex…

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

Re: SSH Examples, Tips and Tunnels

#26

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

Not a gerat solution, but if you did launch something in bash, and you don't care about STDOUT/ERR (or you're directing to a file), you can run "disown %1" to detach it from your shell after you've launched it. The program will continue to run until it finishes naturally (or it's killed)

You can't reattach the program, but there's other ways to auto-launch screen if you're often doing that.

Re: SSH Examples, Tips and Tunnels

#27
post #19

Earlier quoted context omitted.

I see no benefit of running grep locally in any case unless maybe local grep is aliased in a complex way to colorize and decorate the outputs in some other way. Either way this is not a great example as you should just login and run it on the remote machine as running through pipe causes the connection to be established every time unless you keep a persistent connection open behind which is explained in the MultiPlex…

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.

Re: SSH Examples, Tips and Tunnels

#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.

Re: SSH Examples, Tips and Tunnels

#29

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 and other documentation are usually reference oriented. That means they are complete, verbose, detail-oriented and structured around functionality and options.

When learning, however, we often need goal directed material and examples. For multi-purpose tools - and most tools have more than one application, especially for higher level goals - that means there can be many different introductions for the same tool, depending on the learner's goal.

The best tools are compositional. Often it's hard to imagine all the ways a tool can be composed by looking at it in isolation. You need some examples to get the imagination working.

Re: SSH Examples, Tips and Tunnels

#30

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_rsa user@example.com

Post reply on HN