Lua
Lua
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 Lua Downloads
local chilkat = require("chilkat")
local socket = chilkat.Socket.new()
local success = socket:ssh_open_tunnel("ssh.example.com", 22)
if not success then
print(socket.last_error_text)
return
end
-- Authenticate the SSH tunnel session with a login and password.
-- The SSH password should come from a secure source rather than being hard-coded.
local sshPassword = "mySshPassword"
success = socket:ssh_authenticate_pw("sshUser", sshPassword)
if not success then
print(socket.last_error_text)
return
end
print("SSH authentication succeeded.")