打开PTY模式即可
$env = ['PATH' => getenv('PATH'), 'SSH_AUTH_SOCK' => getenv('SSH_AUTH_SOCK')]
$process = new Process(['ssh', 'username@host', 'echo 1'], null, $env);
// turning on PTY support
$process->setPty(true);
$process->run();
echo $process->getOutput();
参考