Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm reading the source code of sshfs. And I find out that when trying to give the password to ssh, it write the password to /dev/ptmx.
write(sshfs.ptyfd, sshfs.password, strlen(sshfs.password));
I know it's the master side of pseudo-terminal, but I don't really understand meaning of writing to it. I tried to echo something to /dev/ptmx but nothing happened. Maybe I'm not fully understand the mechanism of pts and ptmx.
The idea of ptmx is that your application creates a virtual console for communication with other applications or with the operating system.
By opening ptmx, an application gets a filed descriptor (basically a number) which gives your application the possibility to communicate over a virtual terminal with other applications.
These other applications can open your terminal by opening /dev/pts/12345 for example.
Echo'ing to /dev/ptmx makes no sense because the only function of /dev/ptmx is to provide your application with a file descriptor of a newly created /dev/pts/ device which can be used by echo.
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.