[EdLUG] SSH - ssh-copy-id problem | RPi | Ubuntu.
Robert McWilliam
rmcw at allmail.net
Tue Mar 30 13:40:18 UTC 2021
On Tue, 30 Mar 2021, at 13:09, Justin B Rye wrote:
> > pstree -sup $(ps aux | grep sshd | awk '{print $2}' | sort -n | head -n 1)
> >
>
> As a general rule of thumb, any complicated pipeline like that is
> really a job for pgrep (which you probably get in the same package as
> ps). The above simplifies down to
>
> pstree -sup $(pgrep sshd)
You've thrown away a bit too much of the pipeline there: pgrep will give multiple results if there are SSH sessions and only want one for pstree so need the head part (and possibly the sort - I think ps and pgrep will give processes in order of PID without having to sort but chucking sort in the pipeline was quicker than checking).
I tend to use ps piped to grep rather than pgrep as it gives more info while I'm playing around to figure out what filter I need to get the right process(es).
Yes, just explaining where to manually copy the PID from is probably easier, but where's the fun in that :)
Robert
________________________________________________________
Robert McWilliam rmcw at allmail.net argh.technology
What do you consider to be your median achievement?
More information about the EdLUG
mailing list