Is there any way to control which pseudo-terminal (/dev/pts/*) a connection is given? For example, I have multiple thin clients each running individual terminal sessions to a RHEL server over SSH, I would like to configure something so that thin client A is always allocated /dev/pts/7 and thin client B is always /dev/pts/8. I have been trying to create a udev rule but udevinfo only returns "couldn't get the class device" when I run it against the terminal ID, I'm not sure how to create a rule if the device is not actually classed in udev.
Linux normally uses the Unix 98 pseudoterminal interface. Entries in
/dev/pts are assigned outside the application's control. An application that wants to create a pseudoterminal (here the SSH server) opens
/dev/ptmx, which allocates a pseudoterminal and returns a file descriptor to it. The pseudoterminal number (the number after
/dev/pts/) determined when the pseudoterminal is allocated; it's tied to the index of the pseudoterminal in a kernel data structure.
(If you're curious, the kernel code is
drivers/tty/pty.c, which calls on
fs/devpts/inode.c, which uses
lib/idr.c. This happens to return the first number available, though there is no guarantee that it will always do so.)
Neither the C API nor the kernel API allows the creator of the pseudoterminal to pass a parameter that would influence the result.
It may be possible to get a static pty by using the legacy BSD API that produces ptys of the form
/dev/ptyNUM (master) and
/dev/ttyNUM (slave). This would at a minimum require recompiling the SSH server without the
HAVE_DEV_PTMX configure setting to force it to use BSD-style ptys. You would need to take care of permissions, though if SSH is the only user it might be a bit easier. Then you would need to patch OpenSSH to add some mechanism to tie a particular pty number to a particular client.
I would strongly recommend against this: it's a nonstandard configuration, requiring you to write some extra code. It's an extra maintenance effort and a security risk.
I don't see the point anyway. You can run
last to see what client is currently logged in on each terminal.