Live data from Hacker News

SSH Examples, Tips and Tunnels

hackertarget.com

51–60 of 72 posts

Re: SSH Examples, Tips and Tunnels

#51
I would like to propose the author add a section for chroot sftp and ways to replicate rsync-like behavior, thus allowing rapid file transfer without providing a shell. [1] This is useful in situations where automated file transfers and backups are required and minimizing risk of shell access is desired.

[1] - https://tinyvpn.org/sftp/#lftp

This specific example can be used to set up public semi-anonymous file sharing without providing shell access. there is a working live demo of the sftp server that you can play around with using lftp to replicate rsync like behavior.

Re: SSH Examples, Tips and Tunnels

#52

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…

I think you are dead wrong with this plea. Explanation and reference are two very different things, and both can't exist effectively in the same document. The man pages are great once you have the concepts down. But there's a huge gap out there for introductory explanations of the concepts behind the tools that the man pages (rightfully) assume you already have mastered. This article is a great example of the type of thing we need a lot more of.

If you know you want a SOCKS proxy and just need to know the correct option name, the man pages are great. If you have no idea what a SOCKS proxy is, why you might want it, or even that ssh can solve this problem for you, then there's no chance you'd even think to look at the man pages for ssh and ssh_config, and if you did, you still wouldn't really know what the bits about SOCKS proxy meant for you and your problems.

It's not like this article's existence will prevent people from reading the man pages. On the contrary, this article serves an entirely different purpose. I can read it on my phone, learn about something new, and then when I'm back at my workstation, I can look up the new concept in the man pages to figure out how I can integrate it into my own workflow.

I'm struggling with understanding the motivation behind your post here. Please reconsider the value of this sort of article in combination with the value of man pages.

Re: SSH Examples, Tips and Tunnels

#53
As an additional tip, I've seen people complain about scp's handling of spaces and other special characters, causing one to use 2 layers of quoting. For example:

  scp machine:'"file with spaces"' .
What people don't tend to realize is that this is because scp allows you to specify the remote-side files with remote shell code. For example, to get all pdfs in the remote home directory:

  scp machine:'*.pdf' .
To get file.xml and file.pdf from the remote:

  scp machine:'file.{xml,pdf}' .
To get the newest file (asumming that it has no whitespace or glob characters):

  scp machine:'$(ls -t | head -1)' .
The same, but handling spaces and other characters, but not newlines:

  scp machine:'"$(ls -t | head -1)"' .
If you use zsh on the remote machine with extended globs, this is the safest way:

  scp machine:'*(oc[1])' .

Re: SSH Examples, Tips and Tunnels

#54

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_…

This is how every man page starts, with a "SYNOPSIS" of invocation. For example the ssh man page starts:

    ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec] ...
If there are several incompatible ways to invoke an operation several cases are given, e.g.

    netstat [-AaLlnW] [-f address_family | -p protocol]
    netstat [-gilns] [-v] [-f address_family] [-I interface]
    ...
Typically there are examples in the EXAMPLES or USAGE section which you can jump straight to via /^U or /^E

In the case of ssh there are several such sections so just jump to them via /^[^ ]

Re: SSH Examples, Tips and Tunnels

#55

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

Pardon my ignorance. Why are screen/tmux so popular ? I just use a terminal with tabs (i.e. Gnome terminal)

Re: SSH Examples, Tips and Tunnels

#56
post #54

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_…

This is how every man page starts, with a "SYNOPSIS" of invocation. For example the ssh man page starts: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec] ... If there are several incompatible ways to invoke an operation several cases are given, e.g. netstat [-AaLlnW] [-f address_family | -p protocol] netstat [-gilns] [-v] [-f address_family] [-I interface] ... Typically there are…

      > ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec] ...
That's exactly the kind of "SYNOPSIS" would make me want to stomp on puppies when looking at a man page because I forgot some basic usage.

But actually, thanks for the key-combo tip on jumping straight to examples.

Re: SSH Examples, Tips and Tunnels

#57

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…

I think you are dead wrong with this plea. Explanation and reference are two very different things, and both can't exist effectively in the same document. The man pages are great once you have the concepts down. But there's a huge gap out there for introductory explanations of the concepts behind the tools that the man pages (rightfully) assume you already have mastered. This article is a great example of the type of…

I find myself agreeing with both of you. You're right that having articles like this makes the tools more accessible and understandable to those that use both resources. However, it seems that most people don't use both resources. Many rely only on these sorts of articles and don't RTFM. There is a lot of power in many *nix tools that people could benefit from but don't realize it because they don't even skim over the manual.

It wasn't that long ago that it was common for people read the manuals of the things they used to get the best bang for their buck, so to speak. Now, the world is filled with quick-starts and use-specific guides, because people don't have the time to research all the things they use.

It's this aversion to a little studying of the tools of our trade that I think blueflow and myself are against.

Re: SSH Examples, Tips and Tunnels

#58
post #54

Earlier quoted context omitted.

This is how every man page starts, with a "SYNOPSIS" of invocation. For example the ssh man page starts: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec] ... If there are several incompatible ways to invoke an operation several cases are given, e.g. netstat [-AaLlnW] [-f address_family | -p protocol] netstat [-gilns] [-v] [-f address_family] [-I interface] ... Typically there are…

> ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec] ... That's exactly the kind of "SYNOPSIS" would make me want to stomp on puppies when looking at a man page because I forgot some basic usage. But actually, thanks for the key-combo tip on jumping straight to examples.

I find many manpages to be pretty obtuse. They could do a lot to help those of us who need a bit more hand holding.

I like cheat.sh. You can curl it directly from your terminal and it offers the quick examples I often need to get back to work.

Here is their ssh page: http://cheat.sh/ssh

Also I am a huge fan of Matlab’s Documentation, at least up to the more recent versions that became less usable. They give a clear description of the function, list syntax options, give several examples and provide a see also section with similar or related functions (greatly helping discoverability). They usually include academic references at the end.

https://uk.mathworks.com/help/matlab/ref/atand.html?s_tid=do...

Re: SSH Examples, Tips and Tunnels

#59
post #54

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_…

This is how every man page starts, with a "SYNOPSIS" of invocation. For example the ssh man page starts: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec] ... If there are several incompatible ways to invoke an operation several cases are given, e.g. netstat [-AaLlnW] [-f address_family | -p protocol] netstat [-gilns] [-v] [-f address_family] [-I interface] ... Typically there are…

Sorry, in my Ubuntu 18.04 "man ssh" produces output that does not have either EXAMPLES or USAGE. /^E takes me to ENVIRONMENT instrad of EXAMPLES.

Re: SSH Examples, Tips and Tunnels

#60

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…

Cookbooks are also important. Sure, if you learn every single ingredients you might be a good cook... but if you read recipes, you will be able to cook well no matter what.
Post reply on HN