I was wondering how openssh gets the password when login, cause I got stuck in automating entering passwords to the similar tools in linux which requires getting password from tty like ssh.
Tried to understand sshpass and found that sshpass forks a child process with the same pid then enters the password under the child process.
Don't know if my guess was right that ssh needs to check the right pid since I cannot stdin to the current tty using another process to enter the ssh password.
See Question&Answers more detail:os