PowerBuilder
PowerBuilder
Get SSH Server Authentication Methods
See more SSH Examples
Demonstrates how to get the authentication methods of an SSH server.This example requires Chilkat v9.5.0.78 or greater.
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Ssh
string ls_AuthMethods
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Ssh = create oleobject
li_rc = loo_Ssh.ConnectToNewObject("Chilkat.Ssh")
if li_rc < 0 then
destroy loo_Ssh
MessageBox("Error","Connecting to COM object failed")
return
end if
// To get the authentication methods offered by an SSH server, we first connect.
li_Success = loo_Ssh.Connect("example.com",22)
if li_Success <> 1 then
Write-Debug loo_Ssh.LastErrorText
destroy loo_Ssh
return
end if
// Next, we call GetAuthMethods to receive a comma separated list of authentication methods
ls_AuthMethods = loo_Ssh.GetAuthMethods()
if loo_Ssh.LastMethodSuccess <> 1 then
Write-Debug loo_Ssh.LastErrorText
destroy loo_Ssh
return
end if
// For example: publickey,password,keyboard-interactive
Write-Debug "Authentication methods suported by this serve: " + ls_AuthMethods
// IMPORTANT:
// Getting the authentication methods will intentionally disconnect from the server.
// We'll need to re-connect, etc. to continue..
// For example..
li_Success = loo_Ssh.Connect("example.com",22)
if li_Success <> 1 then
Write-Debug loo_Ssh.LastErrorText
destroy loo_Ssh
return
end if
li_Success = loo_Ssh.AuthenticatePw("myLogin","myPassword")
if li_Success <> 1 then
Write-Debug loo_Ssh.LastErrorText
destroy loo_Ssh
return
end if
Write-Debug "SSH Authentication successful."
// ...
loo_Ssh.Disconnect()
destroy loo_Ssh