Detect PID of sshd processes used by one public key; detect -R allocated port on the server

Alex Bligh alex at alex.org.uk
Sun Oct 9 00:20:09 EST 2011



--On 8 October 2011 08:06:59 -0400 Stephen Harris <lists at spuddy.org> wrote:

>> no-agent-forwarding,command="/bin/true",no-pty,no-user-rc,no-X11-forward
>> ing,permitopen="127.0.0.1:7"
>
>> But there seems to be no way to get the PIDs of an ssh process associated
>> with a particular public key, as opposed to a particular user.
>
> Instead of command="/bin/true" use command="/path/to/script".  The script
> can look at parent processes and work up the tree until it reaches the
> sshd process.

(I hope you don't mind me sending the reply to the list)

This strategy does not work for two reasons:

1. when -N is used, command= / ForceCommand is not executed. It only forces
   running of a command when there is either an interactive session
   requested or a command on the command line.

2. (less of an issue), the user's shell can no longer be /bin/false; it has
   to be a real shell.

-- 
Alex Bligh


More information about the openssh-unix-dev mailing list