NetBurner 3.5.0
PDF Version
 
SSH

Topics

 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.
 
typedef int(* sshUserAuthenticateWithTypeFn) (const char *usernamePtr, const char *authValPtr, AuthType authType)
 User provided SSH user authenticate routine for a server.
 
typedef int(* sshGetUserPwFn) (const NBString &usernamePtr, NBString &passwordPtr)
 User provided SSH user password authentication routine for clients.
 
typedef int(* sshGetUserKeyFn) (const NBString &usernamePtr, NBString &publicKey, NBString &privateKey, NBString &keyType)
 User provided SSH user key authenticate routine for clients.
 
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.
 

Functions

void SshSetUserAuthenticate (sshUserAuthenticateFn sshUserAuthenticateFnPtr)
 [DEPRECATED] Sets the user defined server authentication function. Please consider sshUserAuthenticateWithTypeFn.
 
sshUserAuthenticateFn SshGetUserAuthenticate (void)
 [DEPRECATED] Gets the user defined server authentication function. Please consider SshGetUserAuthenticateWithType.
 
void SshSetUserAuthenticateWithType (sshUserAuthenticateWithTypeFn sshUserAuthenticateFnPtr)
 Sets the user defined server authentication function.
 
sshUserAuthenticateWithTypeFn SshGetUserAuthenticateWithType (void)
 Gets the user defined server authentication function..
 
void SshClientSetGetUserPaswordFn (sshGetUserPwFn sshGetUserPwFnPtr)
 Sets the user defined client authentication function for getting user passwords during SSH authentication.
 
sshGetUserPwFn SshClientGetUserPaswordFn (void)
 Gets the user defined client authentication function for getting a user password during authentication.
 
void SshClientSetGetUserKeyFn (sshGetUserKeyFn sshGetUserKeyFnPtr)
 Sets the user defined client authentication function for getting user keys during SSH authentication.
 
sshGetUserKeyFn SshClientGetUserKeyFn (void)
 Gets the user defined client authentication function for getting a user key during authentication.
 
void SshSetUserGetKey (sshUserGetKeyFn sshUserGetKeyFnPtr)
 Sets the user defined callback method to provide the server key.
 
sshUserGetKeyFn SshGetUserGetKey (void)
 Gets the user defined callback method to provide the server key.
 
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.
 
bool SshWritePublicKey (int publicKeyFd, unsigned char *candidateKey, int candidateKeySize)
 Write public key to file descriptor. Takes both PEM and ANS1 formats.
 
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.
 
int SshAccept (int listenFd, IPADDR *clientAddress, uint16_t *securePort, uint16_t timeout)
 Accepts and negotiates SSH session. Automatically calls NbSshInit() if required.
 
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.
 
SshSocket * SshNegotiateSession (int fd)
 Negotiates an SSH server session on an open file descriptor.
 
SshSocket * SshNegotiateSessionClient (int secureFd, const char *username)
 Negotiates an SSH client session on an open file descriptor.
 
void SshPrintStatistics (int secureFd)
 Negotiates an SSH client session on an open file descriptor.
 
int SshGetKeySize ()
 Determins and returns SSH's installed key size.
 
int SshSetBannerText (const char *banner)
 Sets the banner text displayed by the SSH server on connection.
 
int SshSetSockOption (int fd, int option)
 Set SSH TCP socket options.
 
int SshClrSockOption (int fd, int option)
 Clear SSH TCP socket options.
 
int SshGetSockOption (int fd)
 Returns the options for the specified SSH TCP socket.
 

Detailed Description

The NetBurner SSH Library

Typedef Documentation

◆ sshGetUserKeyFn

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

#include <NbWolfSsh.h>

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
>0Password available for the user
<=0Authentication failed

◆ sshGetUserPwFn

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

#include <NbWolfSsh.h>

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
>0Password available for the user
<=0Authentication failed

◆ sshUserAuthenticateFn

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

#include <NbWolfSsh.h>

[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)

#include <NbWolfSsh.h>

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)

#include <NbWolfSsh.h>

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 ( )

#include <NbWolfSsh.h>

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 )

#include <NbWolfSsh.h>

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 )

#include <NbWolfSsh.h>

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 )

#include <NbWolfSsh.h>

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)

#include <NbWolfSsh.h>

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)

#include <NbWolfSsh.h>

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 )

#include <NbWolfSsh.h>

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 )

#include <NbWolfSsh.h>

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 ( )

#include <NbWolfSsh.h>

Determins and returns SSH's installed key size.

Returns
The installed key's size

◆ SshGetSockOption()

int SshGetSockOption ( int fd)

#include <NbWolfSsh.h>

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 )

#include <NbWolfSsh.h>

[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 )

#include <NbWolfSsh.h>

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 )

#include <NbWolfSsh.h>

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)

#include <NbWolfSsh.h>

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 )

#include <NbWolfSsh.h>

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)

#include <NbWolfSsh.h>

Negotiates an SSH client session on an open file descriptor.

Parameters
secureFdSecure file descriptor

◆ SshSetBannerText()

int SshSetBannerText ( const char * banner)

#include <NbWolfSsh.h>

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 )

#include <NbWolfSsh.h>

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)

#include <NbWolfSsh.h>

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

Parameters
sshUserAuthenticateFnPtrFuction to set
See also
SshSetUserAuthenticateWithType()

◆ SshSetUserAuthenticateWithType()

void SshSetUserAuthenticateWithType ( sshUserAuthenticateWithTypeFn sshUserAuthenticateFnPtr)

#include <NbWolfSsh.h>

Sets the user defined server authentication function.

Parameters
sshUserAuthenticateFnPtrFuction to set
See also
SshSetUserAuthenticateWithType()

◆ SshSetUserGetKey()

void SshSetUserGetKey ( sshUserGetKeyFn sshUserGetKeyFnPtr)

#include <NbWolfSsh.h>

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 )

#include <NbWolfSsh.h>

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 )

#include <NbWolfSsh.h>

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