NetBurner 3.3.9
PDF Version
SSH

Modules

 SSH Error Codes
 

Typedefs

typedef int(* sshUserAuthenticateFn) (const char *usernamePtr, const char *passwordPtr)
 [DEPRECATED] User provided SSH username and password authenticate routine for a server. Please consider sshUserAuthenticateWithTypeFn. More...
 
typedef int(* sshUserAuthenticateWithTypeFn) (const char *usernamePtr, const char *authValPtr, AuthType authType)
 User provided SSH user authenticate routine for a server. More...
 
typedef int(* sshGetUserPwFn) (const NBString &usernamePtr, NBString &passwordPtr)
 User provided SSH user password authentication routine for clients. More...
 
typedef int(* sshGetUserKeyFn) (const NBString &usernamePtr, NBString &publicKey, NBString &privateKey, NBString &keyType)
 User provided SSH user key authenticate routine for clients. More...
 
typedef int(* sshUserGetKeyFn) (int keyRequested, const unsigned char **keyBufferPtr, int *keyLengthPtr)
 The user defined callback to get the server key used during the initial SSH negotiation. More...
 

Functions

void SshSetUserAuthenticate (sshUserAuthenticateFn sshUserAuthenticateFnPtr)
 [DEPRECATED] Sets the user defined server authentication function. Please consider sshUserAuthenticateWithTypeFn. More...
 
sshUserAuthenticateFn SshGetUserAuthenticate (void)
 [DEPRECATED] Gets the user defined server authentication function. Please consider SshGetUserAuthenticateWithType. More...
 
void SshSetUserAuthenticateWithType (sshUserAuthenticateWithTypeFn sshUserAuthenticateFnPtr)
 Sets the user defined server authentication function. More...
 
sshUserAuthenticateWithTypeFn SshGetUserAuthenticateWithType (void)
 Gets the user defined server authentication function.. More...
 
void SshClientSetGetUserPaswordFn (sshGetUserPwFn sshGetUserPwFnPtr)
 Sets the user defined client authentication function for getting user passwords during SSH authentication. More...
 
sshGetUserPwFn SshClientGetUserPaswordFn (void)
 Gets the user defined client authentication function for getting a user password during authentication. More...
 
void SshClientSetGetUserKeyFn (sshGetUserKeyFn sshGetUserKeyFnPtr)
 Sets the user defined client authentication function for getting user keys during SSH authentication. More...
 
sshGetUserKeyFn SshClientGetUserKeyFn (void)
 Gets the user defined client authentication function for getting a user key during authentication. More...
 
void SshSetUserGetKey (sshUserGetKeyFn sshUserGetKeyFnPtr)
 Sets the user defined callback method to provide the server key. More...
 
sshUserGetKeyFn SshGetUserGetKey (void)
 Gets the user defined callback method to provide the server key. More...
 
bool SshValidateKey (const char *candidateKey, int candidateKeySize, int *keyTypePtr, int keyFormat=WOLFSSH_FORMAT_ASN1)
 Takes a key and returns if it's valid or not. More...
 
bool SshWritePublicKey (int publicKeyFd, unsigned char *candidateKey, int candidateKeySize)
 Write public key to file descriptor. Takes both PEM and ANS1 formats. More...
 
int NbSshInit ()
 Initializes the underlying SSH framework. This will start a background task used to handle negotiations and SSH traffic. This is automatically called by SshAccept and SshConnect, and doesn't need to be called directly except in special circumstances. More...
 
int SshAccept (int listenFd, IPADDR *clientAddress, uint16_t *securePort, uint16_t timeout)
 Accepts and negotiates SSH session. Automatically calls NbSshInit() if required. More...
 
int SshConnect (IPADDR clientAddress, uint16_t securePort, uint16_t localPort, uint16_t timeout, const char *username)
 Issues a connect request to negotiates an SSH session. Automatically calls NbSshInit() if required. More...
 
SshSocket * SshNegotiateSession (int fd)
 Negotiates an SSH server session on an open file descriptor. More...
 
SshSocket * SshNegotiateSessionClient (int secureFd, const char *username)
 Negotiates an SSH client session on an open file descriptor. More...
 
void SshPrintStatistics (int secureFd)
 Negotiates an SSH client session on an open file descriptor. More...
 
int SshGetKeySize ()
 Determins and returns SSH's installed key size. More...
 
int SshSetBannerText (const char *banner)
 Sets the banner text displayed by the SSH server on connection. More...
 
int SshSetSockOption (int fd, int option)
 Set SSH TCP socket options. More...
 
int SshClrSockOption (int fd, int option)
 Clear SSH TCP socket options. More...
 
int SshGetSockOption (int fd)
 Returns the options for the specified SSH TCP socket. More...
 

Detailed Description

The NetBurner SSH Library

Typedef Documentation

◆ sshGetUserKeyFn

typedef int(* sshGetUserKeyFn) (const NBString &usernamePtr, NBString &publicKey, NBString &privateKey, NBString &keyType)

User provided SSH user key authenticate routine for clients.

Parameters
usernamePtrUsername in plain text
[out]publicKeyUsed to return the corresponding public key for the user
[out]privateKeyUsed to return the corresponding pviate key for the user
[out]keyTypeUsed to return the corresponding key type (ECC or RSA) for the user
Return values
>0Pasword available for the user
<=0Authentication failed

◆ sshGetUserPwFn

typedef int(* sshGetUserPwFn) (const NBString &usernamePtr, NBString &passwordPtr)

User provided SSH user password authentication routine for clients.

Parameters
usernamePtrUsername in plain text
[out]passwordPtrUsed to return the corresponding password for the user
Return values
>0Pasword available for the user
<=0Authentication failed

◆ sshUserAuthenticateFn

typedef int(* sshUserAuthenticateFn) (const char *usernamePtr, const char *passwordPtr)

[DEPRECATED] User provided SSH username and password authenticate routine for a server. Please consider sshUserAuthenticateWithTypeFn.

Parameters
usernamePtrUsername in plain text
passwordPtrPassword in plain text
Return values
1Authentication passed
!1Authentication failed

◆ sshUserAuthenticateWithTypeFn

typedef int(* sshUserAuthenticateWithTypeFn) (const char *usernamePtr, const char *authValPtr, AuthType authType)

User provided SSH user authenticate routine for a server.

Parameters
usernamePtrUsername in plain text
authValPtrThe value that is being passed in for authentication
authTypeEither a password or a key
Return values
1Authentication passed
!1Authentication failed

◆ sshUserGetKeyFn

typedef int(* sshUserGetKeyFn) (int keyRequested, const unsigned char **keyBufferPtr, int *keyLengthPtr)

The user defined callback to get the server key used during the initial SSH negotiation.

Parameters
keyRequestedType key requested (ECC or RSA)
keyBufferPtrBuffer containing the key (ASN1 or PEM format supported)
keyLengthPtrSize of the key in 8 bit bytes
Return values
0Key and length are valid
-1Key requested is not available
See also
SshSetUserGetKey()
SshGetUserGetKey()

Function Documentation

◆ NbSshInit()

int NbSshInit ( )

Initializes the underlying SSH framework. This will start a background task used to handle negotiations and SSH traffic. This is automatically called by SshAccept and SshConnect, and doesn't need to be called directly except in special circumstances.

Return values
SSH_SUCCESSif SSH system has been correctly initialized.
OtherSSH error code if initialization was unsuccessful.
See also
SshAccept()
SshConnect()

◆ SshAccept()

int SshAccept ( int  listenFd,
IPADDR clientAddress,
uint16_t *  securePort,
uint16_t  timeout 
)

Accepts and negotiates SSH session. Automatically calls NbSshInit() if required.

Parameters
listenFdFile descriptor of listening socket
clientAddressAddress of client
securePortSecure port of negotiated socket
timeoutTicks to wait for connection, 0 is infinite
Return values
>0The secure file descriptor if successful.
OtherA TCP or SSH error code, depending on the error..
See also
NbSshInit()
SshConnect()

◆ SshClientGetUserKeyFn()

sshGetUserKeyFn SshClientGetUserKeyFn ( void  )

Gets the user defined client authentication function for getting a user key during authentication.

Return values
sshGetUserPwFnPtrSets the user defined server authentication function.
See also
SshClientSetGetUserPaswordFn()
SshClientGetUserPaswordFn()
SshClientSetGetUserKeyFn()

◆ SshClientGetUserPaswordFn()

sshGetUserPwFn SshClientGetUserPaswordFn ( void  )

Gets the user defined client authentication function for getting a user password during authentication.

Return values
Apointer to the fuction that is currently set for passing in a user's password during authentication.
See also
SshClientSetGetUserPaswordFn()
SshClientSetGetUserKeyFn()
SshClientGetUserKeyFn()

◆ SshClientSetGetUserKeyFn()

void SshClientSetGetUserKeyFn ( sshGetUserKeyFn  sshGetUserKeyFnPtr)

Sets the user defined client authentication function for getting user keys during SSH authentication.

Parameters
sshGetUserKeyFnPtrSets the user defined server authentication function.
See also
SshClientSetGetUserPaswordFn()
SshClientGetUserPaswordFn()
SshClientGetUserKeyFn()

◆ SshClientSetGetUserPaswordFn()

void SshClientSetGetUserPaswordFn ( sshGetUserPwFn  sshGetUserPwFnPtr)

Sets the user defined client authentication function for getting user passwords during SSH authentication.

Parameters
sshGetUserPwFnPtrSets the user defined client authentication function.
See also
SshClientGetUserPaswordFn()
SshClientSetGetUserKeyFn()
SshClientGetUserKeyFn()

◆ SshClrSockOption()

int SshClrSockOption ( int  fd,
int  option 
)

Clear SSH TCP socket options.

Parameters
fdSocket file descriptor.
optionSocket option to clear: TCP Socket Options.
Returns
A bitmask of the options for the specified socket
See also
SshSetSockOption()
SshGetSockOption()

◆ SshConnect()

int SshConnect ( IPADDR  clientAddress,
uint16_t  securePort,
uint16_t  localPort,
uint16_t  timeout,
const char *  username 
)

Issues a connect request to negotiates an SSH session. Automatically calls NbSshInit() if required.

Parameters
clientAddressAddress of client
securePortSecure port of negotiated socket
localPortOptional parameter to specify a Local port number. Recommend this always be set to a value of 0 so a random local port number is used.
timeoutTicks to wait for connection, 0 is infinite
usernameUsername to use in negotiation process of secure connection
Return values
>0The secure file descriptor if successful.
0Request timed out.
<0A TCP or SSH error code, depending on the error..
See also
SshAccept()
NbSshInit()

◆ SshGetKeySize()

int SshGetKeySize ( )

Determins and returns SSH's installed key size.

Returns
The installed key's size

◆ SshGetSockOption()

int SshGetSockOption ( int  fd)

Returns the options for the specified SSH TCP socket.

Parameters
fdSocket file descriptor.
Returns
A bitmask of the options for the specified socket
See also
SshSetSockOption()
SshClrSockOption()

◆ SshGetUserAuthenticate()

sshUserAuthenticateFn SshGetUserAuthenticate ( void  )

[DEPRECATED] Gets the user defined server authentication function. Please consider SshGetUserAuthenticateWithType.

Return values
Returnsa pointer to the function fuction that is currently set for server user authentication.
See also
SshGetUserAuthenticateWithType

◆ SshGetUserAuthenticateWithType()

sshUserAuthenticateWithTypeFn SshGetUserAuthenticateWithType ( void  )

Gets the user defined server authentication function..

Return values
Apointer to the fuction that is currently set for server user authentication.
See also
SshGetUserAuthenticateWithType()

◆ SshGetUserGetKey()

sshUserGetKeyFn SshGetUserGetKey ( void  )

Gets the user defined callback method to provide the server key.

Return values
sshUserGetKeyFnThe user defined callback
See also
sshUserGetKeyFn()
SshSetUserGetKey()

◆ SshNegotiateSession()

SshSocket * SshNegotiateSession ( int  fd)

Negotiates an SSH server session on an open file descriptor.

Parameters
fdFile descriptor to use in the SSN negotiation, usually obtained with a call to accept()
Returns
A pointer to the SSH socket created on a successfull connection, or a nullptr if not successful.

◆ SshNegotiateSessionClient()

SshSocket * SshNegotiateSessionClient ( int  secureFd,
const char *  username 
)

Negotiates an SSH client session on an open file descriptor.

Parameters
secureFdFile descriptor to use in the SSN negotiation
usernameUsername to use in negotiation process of secure connection
Returns
A pointer to the SSH socket created on a successfull connection, or a nullptr if not successful.

◆ SshPrintStatistics()

void SshPrintStatistics ( int  secureFd)

Negotiates an SSH client session on an open file descriptor.

Parameters
secureFdSecure file descriptor

◆ SshSetBannerText()

int SshSetBannerText ( const char *  banner)

Sets the banner text displayed by the SSH server on connection.

Parameters
bannerThe text to display to any connected clients
Return values
SSH_SUCCESSIf successful
<0Error code on failure

◆ SshSetSockOption()

int SshSetSockOption ( int  fd,
int  option 
)

Set SSH TCP socket options.

Parameters
fdSocket file descriptor.
optionSocket option to set: TCP Socket Options.
Returns
A bitmask of the options for the specified socket
See also
SshClrSockOption()
SshGetSockOption()

◆ SshSetUserAuthenticate()

void SshSetUserAuthenticate ( sshUserAuthenticateFn  sshUserAuthenticateFnPtr)

[DEPRECATED] Sets the user defined server authentication function. Please consider sshUserAuthenticateWithTypeFn.

Parameters
sshUserAuthenticateFnPtrFuction to set
See also
SshSetUserAuthenticateWithType()

◆ SshSetUserAuthenticateWithType()

void SshSetUserAuthenticateWithType ( sshUserAuthenticateWithTypeFn  sshUserAuthenticateFnPtr)

Sets the user defined server authentication function.

Parameters
sshUserAuthenticateFnPtrFuction to set
See also
SshSetUserAuthenticateWithType()

◆ SshSetUserGetKey()

void SshSetUserGetKey ( sshUserGetKeyFn  sshUserGetKeyFnPtr)

Sets the user defined callback method to provide the server key.

Parameters
sshUserGetKeyFnPtrThe user defined callback
See also
sshUserGetKeyFn()
SshGetUserGetKey()

◆ SshValidateKey()

bool SshValidateKey ( const char *  candidateKey,
int  candidateKeySize,
int *  keyTypePtr,
int  keyFormat = WOLFSSH_FORMAT_ASN1 
)

Takes a key and returns if it's valid or not.

Parameters
candidateKeyA pointer to a buffer containing the key
candidateKeySizeThe size of the key in bytes
[out]keyTypePtrIs set to what kind of key is passed it (ECC and RSA are valid)
keyFormatThe key format (ASN1 or PEM)
Return values
trueThe key is valid
falseThe key is not valid

◆ SshWritePublicKey()

bool SshWritePublicKey ( int  publicKeyFd,
unsigned char *  candidateKey,
int  candidateKeySize 
)

Write public key to file descriptor. Takes both PEM and ANS1 formats.

Parameters
publicKeyFdOpen target file descriptor
candidateKeykey in buffer
candidateKeySizeSize of key in bytes
Return values
trueA valid key was written to the file descriptor
falseAn error occurred