PHP
Chilkat2 PHP
Authenticate an SSH Tunnel with a Password
See more Socket/SSL/TLS Examples
Demonstrates Socket.SshAuthenticatePw, which authenticates an SSH tunnel session using a login and password. Call SshOpenTunnel first.
Background. Authenticate before opening forwarded channels. The password should come from a secure source and never be logged; public-key authentication is often preferred.
Chilkat PHP Downloads
<?php
use Chilkat2\Socket;
$socket = new Socket();
try {
$socket->SshOpenTunnel('ssh.example.com', 22);
// Authenticate the SSH tunnel session with a login and password.
// The SSH password should come from a secure source rather than being hard-coded.
$sshPassword = 'mySshPassword';
$socket->SshAuthenticatePw('sshUser', $sshPassword);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo "SSH authentication succeeded.\n";