Server SSH
Server

Server-side settings for SSH connections. More...

Collaboration diagram for Server SSH:

## Functions

int | nc_server_ssh_add_authkey (const char *pubkey_base64, NC_SSH_KEY_TYPE type, const char *username)
| Add an authorized client SSH public key. This public key can be used for publickey authentication (for any SSH connection, even Call Home) afterwards. More...
int | nc_server_ssh_add_authkey_path (const char *pubkey_path, const char *username)
| Add an authorized client SSH public key. This public key can be used for publickey authentication (for any SSH connection, even Call Home) afterwards. More...
int | nc_server_ssh_del_authkey (const char *pubkey_path, const char *pubkey_base64, NC_SSH_KEY_TYPE type, const char *username)
| Remove an authorized client SSH public key. More...
int | nc_server_ssh_endpt_add_hostkey (const char *endpt_name, const char *name, int16_t idx)
| Add endpoint SSH host keys the server will identify itself with. Only the name is set, the key itself wil be retrieved using a callback. More...
int | nc_server_ssh_endpt_del_hostkey (const char *endpt_name, const char *name, int16_t idx)
| Delete endpoint SSH host key. Their order is preserved. More...
int | nc_server_ssh_endpt_get_auth_methods (const char *endpt_name)
| Get endpoint accepted SSH authentication methods. More...
int | nc_server_ssh_endpt_mod_hostkey (const char *endpt_name, const char *name, const char *new_name)
| Modify endpoint SSH host key. More...
int | nc_server_ssh_endpt_mov_hostkey (const char *endpt_name, const char *key_mov, const char *key_after)
| Move endpoint SSH host key. More...
int | nc_server_ssh_endpt_set_auth_attempts (const char *endpt_name, uint16_t auth_attempts)
| Set endpoint SSH authentication attempts of every client. 3 by default. More...
int | nc_server_ssh_endpt_set_auth_methods (const char *endpt_name, int auth_methods)
| Set endpoint accepted SSH authentication methods. All (publickey, password, interactive) are supported by default. More...
int | nc_server_ssh_endpt_set_auth_timeout (const char *endpt_name, uint16_t auth_timeout)
| Set endpoint SSH authentication timeout. 30 seconds by default. More...
void | nc_server_ssh_set_hostkey_clb (int(*hostkey_clb)(const char *name, void *user_data, char **privkey_path, char **privkey_data, NC_SSH_KEY_TYPE *privkey_type), void *user_data, void(*free_user_data)(void *user_data))
| Set the callback for retrieving host keys. Any RSA, DSA, and ECDSA keys can be added. However, a maximum of one key of each type will be used during SSH authentication, later keys replacing the earlier ones. More...
void | nc_server_ssh_set_interactive_auth_clb (int(*interactive_auth_clb)(const struct nc_session *session, const ssh_message msg, void *user_data), void *user_data, void(*free_user_data)(void *user_data))
| Set the callback for SSH interactive authentication. If none is set, local system users are used. More...
void | nc_server_ssh_set_passwd_auth_clb (int(*passwd_auth_clb)(const struct nc_session *session, const char *password, void *user_data), void *user_data, void(*free_user_data)(void *user_data))
| Set the callback for SSH password authentication. If none is set, local system users are used. More...
void | nc_server_ssh_set_pubkey_auth_clb (int(*pubkey_auth_clb)(const struct nc_session *session, ssh_key key, void *user_data), void *user_data, void(*free_user_data)(void *user_data))
| Set the callback for SSH public key authentication. If none is set, local system users are used. More...

## Detailed Description

Server-side settings for SSH connections.

## Function Documentation

## nc_server_ssh_add_authkey()

int nc_server_ssh_add_authkey | ( | const char * | pubkey_base64,
|  | NC_SSH_KEY_TYPE | type,
|  | const char * | username
| ) |  |

Add an authorized client SSH public key. This public key can be used for publickey authentication (for any SSH connection, even Call Home) afterwards.

Parameters

  [in] | pubkey_base64 | Authorized public key binary content encoded in base64.
  [in] | type | Authorized public key SSH type.
  [in] | username | Username that the client with the public key must use.

Returns
  0 on success, -1 on error.

## nc_server_ssh_add_authkey_path()

int nc_server_ssh_add_authkey_path | ( | const char * | pubkey_path,
|  | const char * | username
| ) |  |

Add an authorized client SSH public key. This public key can be used for publickey authentication (for any SSH connection, even Call Home) afterwards.

Parameters

  [in] | pubkey_path | Path to the public key.
  [in] | username | Username that the client with the public key must use.

Returns
  0 on success, -1 on error.

## nc_server_ssh_del_authkey()

int nc_server_ssh_del_authkey | ( | const char * | pubkey_path,
|  | const char * | pubkey_base64,
|  | NC_SSH_KEY_TYPE | type,
|  | const char * | username
| ) |  |

Remove an authorized client SSH public key.

Parameters

  [in] | pubkey_path | Path to an authorized public key. NULL matches all the keys.
  [in] | pubkey_base64 | Authorized public key content. NULL matches any key.
  [in] | type | Authorized public key type. 0 matches all types.
  [in] | username | Username for an authorized public key. NULL matches all the usernames.

Returns
  0 on success, -1 on not finding any match.

## nc_server_ssh_endpt_add_hostkey()

int nc_server_ssh_endpt_add_hostkey | ( | const char * | endpt_name,
|  | const char * | name,
|  | int16_t | idx
| ) |  |

Add endpoint SSH host keys the server will identify itself with. Only the name is set, the key itself wil be retrieved using a callback.

Parameters

  [in] | endpt_name | Existing endpoint name.
  [in] | name | Arbitrary name of the host key.
  [in] | idx | Optional index where to add the key. -1 adds at the end.

Returns
  0 on success, -1 on error.

## nc_server_ssh_endpt_del_hostkey()

int nc_server_ssh_endpt_del_hostkey | ( | const char * | endpt_name,
|  | const char * | name,
|  | int16_t | idx
| ) |  |

Delete endpoint SSH host key. Their order is preserved.

Parameters

  [in] | endpt_name | Existing endpoint name.
  [in] | name | Name of the host key. NULL matches all the keys, but if `idx` != -1 then this must be NULL.
  [in] | idx | Index of the hostkey. -1 matches all indices, but if `name` != NULL then this must be -1.

Returns
  0 on success, -1 on error.

## nc_server_ssh_endpt_get_auth_methods()

int nc_server_ssh_endpt_get_auth_methods | ( | const char * | endpt_name | ) |

Get endpoint accepted SSH authentication methods.

Parameters

  [in] | endpt_name | Existing endpoint name.

Returns
  Accepted authentication methods bit field of NC_SSH_AUTH_TYPE.

## nc_server_ssh_endpt_mod_hostkey()

int nc_server_ssh_endpt_mod_hostkey | ( | const char * | endpt_name,
|  | const char * | name,
|  | const char * | new_name
| ) |  |

Modify endpoint SSH host key.

Parameters

  [in] | endpt_name | Exisitng endpoint name.
  [in] | name | Name of an existing host key.
  [in] | new_name | New name of the host key `name`.

Returns
  0 in success, -1 on error.

## nc_server_ssh_endpt_mov_hostkey()

int nc_server_ssh_endpt_mov_hostkey | ( | const char * | endpt_name,
|  | const char * | key_mov,
|  | const char * | key_after
| ) |  |

Move endpoint SSH host key.

Parameters

  [in] | endpt_name | Exisitng endpoint name.
  [in] | key_mov | Name of the host key that will be moved.
  [in] | key_after | Name of the key that will preceed `key_mov`. NULL if `key_mov` is to be moved at the beginning.

Returns
  0 in success, -1 on error.

## nc_server_ssh_endpt_set_auth_attempts()

int nc_server_ssh_endpt_set_auth_attempts | ( | const char * | endpt_name,
|  | uint16_t | auth_attempts
| ) |  |

Set endpoint SSH authentication attempts of every client. 3 by default.

Parameters

  [in] | endpt_name | Existing endpoint name.
  [in] | auth_attempts | Failed authentication attempts before a client is dropped.

Returns
  0 on success, -1 on error.

## nc_server_ssh_endpt_set_auth_methods()

int nc_server_ssh_endpt_set_auth_methods | ( | const char * | endpt_name,
|  | int | auth_methods
| ) |  |

Set endpoint accepted SSH authentication methods. All (publickey, password, interactive) are supported by default.

Parameters

  [in] | endpt_name | Existing endpoint name.
  [in] | auth_methods | Accepted authentication methods bit field of NC_SSH_AUTH_TYPE.

Returns
  0 on success, -1 on error.

## nc_server_ssh_endpt_set_auth_timeout()

int nc_server_ssh_endpt_set_auth_timeout | ( | const char * | endpt_name,
|  | uint16_t | auth_timeout
| ) |  |

Set endpoint SSH authentication timeout. 30 seconds by default.

Parameters

  [in] | endpt_name | Existing endpoint name.
  [in] | auth_timeout | Number of seconds before an unauthenticated client is dropped.

Returns
  0 on success, -1 on error.

## nc_server_ssh_set_hostkey_clb()

void nc_server_ssh_set_hostkey_clb | ( | int(*)(const char *name, void *user_data, char **privkey_path, char **privkey_data, NC_SSH_KEY_TYPE *privkey_type) | hostkey_clb,
|  | void * | user_data,
|  | void(*)(void *user_data) | free_user_data
| ) |  |

Set the callback for retrieving host keys. Any RSA, DSA, and ECDSA keys can be added. However, a maximum of one key of each type will be used during SSH authentication, later keys replacing the earlier ones.

Parameters

  [in]

  hostkey_clb

  Callback that should return the key itself. Zero return indicates success, non-zero an error. On success exactly ONE of `privkey_path` or `privkey_data` is expected to be set. The one set will be freed.
  - `privkey_path` expects a PEM file,
  - `privkey_data` expects a base-64 encoded ANS.1 DER data,
  - `privkey_type` type of the key in `privkey_data`. Use NC_SSH_KEY_UNKNOWN for PKCS#8 key that includes the information about the key in its data.

  [in] | user_data | Optional arbitrary user data that will be passed to `hostkey_clb`.
  [in] | free_user_data | Optional callback that will be called during cleanup to free any `user_data`.

## nc_server_ssh_set_interactive_auth_clb()

void nc_server_ssh_set_interactive_auth_clb | ( | int(*)(const struct nc_session *session, const ssh_message msg, void *user_data) | interactive_auth_clb,
|  | void * | user_data,
|  | void(*)(void *user_data) | free_user_data
| ) |  |

Set the callback for SSH interactive authentication. If none is set, local system users are used.

Parameters

  [in] | interactive_auth_clb | Callback that should authenticate the user. Zero return indicates success, non-zero an error.
  [in] | user_data | Optional arbitrary user data that will be passed to `passwd_auth_clb`.
  [in] | free_user_data | Optional callback that will be called during cleanup to free any `user_data`.

## nc_server_ssh_set_passwd_auth_clb()

void nc_server_ssh_set_passwd_auth_clb | ( | int(*)(const struct nc_session *session, const char *password, void *user_data) | passwd_auth_clb,
|  | void * | user_data,
|  | void(*)(void *user_data) | free_user_data
| ) |  |

Set the callback for SSH password authentication. If none is set, local system users are used.

Parameters

  [in] | passwd_auth_clb | Callback that should authenticate the user. Username can be directly obtained from `session`. Zero return indicates success, non-zero an error.
  [in] | user_data | Optional arbitrary user data that will be passed to `passwd_auth_clb`.
  [in] | free_user_data | Optional callback that will be called during cleanup to free any `user_data`.

## nc_server_ssh_set_pubkey_auth_clb()

void nc_server_ssh_set_pubkey_auth_clb | ( | int(*)(const struct nc_session *session, ssh_key key, void *user_data) | pubkey_auth_clb,
|  | void * | user_data,
|  | void(*)(void *user_data) | free_user_data
| ) |  |

Set the callback for SSH public key authentication. If none is set, local system users are used.

Parameters

  [in] | pubkey_auth_clb | Callback that should authenticate the user. Zero return indicates success, non-zero an error.
  [in] | user_data | Optional arbitrary user data that will be passed to `passwd_auth_clb`.
  [in] | free_user_data | Optional callback that will be called during cleanup to free any `user_data`.