Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
SSH client/server common API

Data Structures

struct  ssh_channel_event_channel_request
 Data for SSH_CHANNEL_EVENT_REQUEST event. More...
struct  ssh_channel_event_channel_request_result
 Data for SSH_CHANNEL_EVENT_REQUEST_RESULT event. More...
struct  ssh_channel_event
 SSH channel event information. More...
struct  ssh_transport_event_authenticate_result
 Data for SSH_TRANSPORT_EVENT_AUTHENTICATE_RESULT event. More...
struct  ssh_transport_event_channel_open
 Data for SSH_TRANSPORT_EVENT_CHANNEL_OPEN event. More...
struct  ssh_transport_event
 SSH transport event information. More...

Macros

#define SSH_EXTENDED_DATA_STDERR   1
 Extended data type for standard error channel data.

Typedefs

typedef int(* ssh_channel_event_callback_t) (struct ssh_channel *channel, const struct ssh_channel_event *event, void *user_data)
 SSH channel event callback.
typedef int(* ssh_transport_event_callback_t) (struct ssh_transport *transport, const struct ssh_transport_event *event, void *user_data)
 SSH transport event callback.
typedef void(* ssh_service_client_cb_t) (struct ssh_client *ssh, int instance, void *user_data)
 Callback used while iterating over SSH client connections.
typedef void(* ssh_service_server_cb_t) (struct ssh_server *sshd, int instance, void *user_data)
 Callback used while iterating over SSH server connections.

Enumerations

enum  ssh_auth_type { SSH_AUTH_NONE , SSH_AUTH_PASSWORD , SSH_AUTH_PUBKEY }
 Authentication methods supported by SSH transports. More...
enum  ssh_channel_request_type {
  SSH_CHANNEL_REQUEST_UNKNOWN , SSH_CHANNEL_REQUEST_PSEUDO_TERMINAL , SSH_CHANNEL_REQUEST_X11_FORWARD , SSH_CHANNEL_REQUEST_ENV_VAR ,
  SSH_CHANNEL_REQUEST_SHELL , SSH_CHANNEL_REQUEST_EXEC , SSH_CHANNEL_REQUEST_SUBSYSTEM , SSH_CHANNEL_REQUEST_WINDOW_CHANGE ,
  SSH_CHANNEL_REQUEST_FLOW_CONTROL , SSH_CHANNEL_REQUEST_SIGNAL , SSH_CHANNEL_REQUEST_EXIT_STATUS , SSH_CHANNEL_REQUEST_EXIT_SIGNAL
}
 Types of SSH channel requests. More...
enum  ssh_channel_event_type {
  SSH_CHANNEL_EVENT_OPEN_RESULT , SSH_CHANNEL_EVENT_REQUEST , SSH_CHANNEL_EVENT_REQUEST_RESULT , SSH_CHANNEL_EVENT_RX_DATA_READY ,
  SSH_CHANNEL_EVENT_TX_DATA_READY , SSH_CHANNEL_EVENT_RX_STDERR_DATA_READY , SSH_CHANNEL_EVENT_EOF , SSH_CHANNEL_EVENT_CLOSED
}
 Types of events emitted for an SSH channel. More...
enum  ssh_transport_event_type { SSH_TRANSPORT_EVENT_CLOSED , SSH_TRANSPORT_EVENT_SERVICE_ACCEPTED , SSH_TRANSPORT_EVENT_AUTHENTICATE_RESULT , SSH_TRANSPORT_EVENT_CHANNEL_OPEN }
 Types of events emitted for an SSH transport. More...

Functions

const char * ssh_transport_client_user_name (struct ssh_transport *transport)
 Get the authenticated client username for a transport.
int ssh_transport_auth_password (struct ssh_transport *transport, const char *user_name, const char *password)
 Authenticate an SSH transport using a password.
int ssh_transport_channel_open (struct ssh_transport *transport, ssh_channel_event_callback_t callback, void *user_data)
 Open a new channel on an SSH transport.
int ssh_channel_open_result (struct ssh_channel *channel, bool success, ssh_channel_event_callback_t callback, void *user_data)
 Reply to a channel open request.
int ssh_channel_request_result (struct ssh_channel *channel, bool success)
 Reply to a channel request.
int ssh_channel_request_shell (struct ssh_channel *channel)
 Request an interactive shell on a channel.
int ssh_channel_read (struct ssh_channel *channel, void *data, uint32_t len)
 Read channel data.
int ssh_channel_write (struct ssh_channel *channel, const void *data, uint32_t len)
 Write channel data.
int ssh_channel_read_stderr (struct ssh_channel *channel, void *data, uint32_t len)
 Read channel standard error data.
int ssh_channel_write_stderr (struct ssh_channel *channel, const void *data, uint32_t len)
 Write channel standard error data.
void ssh_client_foreach (ssh_service_client_cb_t cb, void *user_data)
 Go through all SSH client connections.
void ssh_server_foreach (ssh_service_server_cb_t cb, void *user_data)
 Go through all SSH server connections.

Detailed Description

Since
4.5
Version
0.1.0

Macro Definition Documentation

◆ SSH_EXTENDED_DATA_STDERR

#define SSH_EXTENDED_DATA_STDERR   1

#include <zephyr/net/ssh/common.h>

Extended data type for standard error channel data.

Typedef Documentation

◆ ssh_channel_event_callback_t

typedef int(* ssh_channel_event_callback_t) (struct ssh_channel *channel, const struct ssh_channel_event *event, void *user_data)

#include <zephyr/net/ssh/common.h>

SSH channel event callback.

Parameters
channelPointer to the SSH channel that produced the event.
eventPointer to channel event data.
user_dataUser-provided context pointer.
Returns
0 on success, or a negative error code on failure.

◆ ssh_service_client_cb_t

typedef void(* ssh_service_client_cb_t) (struct ssh_client *ssh, int instance, void *user_data)

#include <zephyr/net/ssh/common.h>

Callback used while iterating over SSH client connections.

Parameters
sshPointer to the SSH client instance
instanceSSH client instance id
user_dataA valid pointer to user data or NULL

◆ ssh_service_server_cb_t

typedef void(* ssh_service_server_cb_t) (struct ssh_server *sshd, int instance, void *user_data)

#include <zephyr/net/ssh/common.h>

Callback used while iterating over SSH server connections.

Parameters
sshdPointer to the SSH server instance
instanceSSH server instance id
user_dataA valid pointer to user data or NULL

◆ ssh_transport_event_callback_t

typedef int(* ssh_transport_event_callback_t) (struct ssh_transport *transport, const struct ssh_transport_event *event, void *user_data)

#include <zephyr/net/ssh/common.h>

SSH transport event callback.

Parameters
transportPointer to the SSH transport that produced the event.
eventPointer to transport event data.
user_dataUser-provided context pointer.
Returns
0 on success, or a negative error code on failure.

Enumeration Type Documentation

◆ ssh_auth_type

#include <zephyr/net/ssh/common.h>

Authentication methods supported by SSH transports.

Enumerator
SSH_AUTH_NONE 

No authentication method selected.

SSH_AUTH_PASSWORD 

Username and password authentication.

SSH_AUTH_PUBKEY 

Public key authentication.

◆ ssh_channel_event_type

#include <zephyr/net/ssh/common.h>

Types of events emitted for an SSH channel.

Enumerator
SSH_CHANNEL_EVENT_OPEN_RESULT 

Result of an open request on the client side.

SSH_CHANNEL_EVENT_REQUEST 

Incoming channel request on the server side.

SSH_CHANNEL_EVENT_REQUEST_RESULT 

Result of a previously sent channel request on the client side.

SSH_CHANNEL_EVENT_RX_DATA_READY 

Channel data is available to read.

SSH_CHANNEL_EVENT_TX_DATA_READY 

Channel can accept more transmit data.

SSH_CHANNEL_EVENT_RX_STDERR_DATA_READY 

Standard error data is available to read.

SSH_CHANNEL_EVENT_EOF 

End-of-file received for the channel.

SSH_CHANNEL_EVENT_CLOSED 

Channel has been closed.

◆ ssh_channel_request_type

#include <zephyr/net/ssh/common.h>

Types of SSH channel requests.

Enumerator
SSH_CHANNEL_REQUEST_UNKNOWN 

Unknown or unsupported channel request type.

SSH_CHANNEL_REQUEST_PSEUDO_TERMINAL 

Request a pseudo-terminal.

SSH_CHANNEL_REQUEST_X11_FORWARD 

Request X11 forwarding.

SSH_CHANNEL_REQUEST_ENV_VAR 

Set an environment variable.

SSH_CHANNEL_REQUEST_SHELL 

Start an interactive shell.

SSH_CHANNEL_REQUEST_EXEC 

Execute a command.

SSH_CHANNEL_REQUEST_SUBSYSTEM 

Start a subsystem.

SSH_CHANNEL_REQUEST_WINDOW_CHANGE 

Notify of terminal window size changes.

SSH_CHANNEL_REQUEST_FLOW_CONTROL 

Request flow control.

SSH_CHANNEL_REQUEST_SIGNAL 

Send a signal to the remote process.

SSH_CHANNEL_REQUEST_EXIT_STATUS 

Report process exit status.

SSH_CHANNEL_REQUEST_EXIT_SIGNAL 

Report process exit signal.

◆ ssh_transport_event_type

#include <zephyr/net/ssh/common.h>

Types of events emitted for an SSH transport.

Enumerator
SSH_TRANSPORT_EVENT_CLOSED 

Transport has been closed.

SSH_TRANSPORT_EVENT_SERVICE_ACCEPTED 

Requested SSH service was accepted by the peer.

SSH_TRANSPORT_EVENT_AUTHENTICATE_RESULT 

Authentication attempt result.

SSH_TRANSPORT_EVENT_CHANNEL_OPEN 

Server received a request to open a channel.

Function Documentation

◆ ssh_channel_open_result()

int ssh_channel_open_result ( struct ssh_channel * channel,
bool success,
ssh_channel_event_callback_t callback,
void * user_data )

#include <zephyr/net/ssh/common.h>

Reply to a channel open request.

Parameters
channelPointer to the SSH channel.
successTrue to accept the open request, false to reject it.
callbackChannel event callback to associate with the opened channel.
user_dataUser-provided context pointer passed to callback.
Returns
0 on success, or a negative error code on failure.

◆ ssh_channel_read()

int ssh_channel_read ( struct ssh_channel * channel,
void * data,
uint32_t len )

#include <zephyr/net/ssh/common.h>

Read channel data.

Parameters
channelPointer to the SSH channel.
dataBuffer to store the received data.
lenMaximum number of bytes to read.
Returns
Number of bytes read, or a negative error code on failure.

◆ ssh_channel_read_stderr()

int ssh_channel_read_stderr ( struct ssh_channel * channel,
void * data,
uint32_t len )

#include <zephyr/net/ssh/common.h>

Read channel standard error data.

Parameters
channelPointer to the SSH channel.
dataBuffer to store the received standard error data.
lenMaximum number of bytes to read.
Returns
Number of bytes read, or a negative error code on failure.

◆ ssh_channel_request_result()

int ssh_channel_request_result ( struct ssh_channel * channel,
bool success )

#include <zephyr/net/ssh/common.h>

Reply to a channel request.

Parameters
channelPointer to the SSH channel.
successTrue if the request succeeded, false otherwise.
Returns
0 on success, or a negative error code on failure.

◆ ssh_channel_request_shell()

int ssh_channel_request_shell ( struct ssh_channel * channel)

#include <zephyr/net/ssh/common.h>

Request an interactive shell on a channel.

Parameters
channelPointer to the SSH channel.
Returns
0 on success, or a negative error code on failure.

◆ ssh_channel_write()

int ssh_channel_write ( struct ssh_channel * channel,
const void * data,
uint32_t len )

#include <zephyr/net/ssh/common.h>

Write channel data.

Parameters
channelPointer to the SSH channel.
dataBuffer containing data to send.
lenNumber of bytes to write.
Returns
Number of bytes written, or a negative error code on failure.

◆ ssh_channel_write_stderr()

int ssh_channel_write_stderr ( struct ssh_channel * channel,
const void * data,
uint32_t len )

#include <zephyr/net/ssh/common.h>

Write channel standard error data.

Parameters
channelPointer to the SSH channel.
dataBuffer containing standard error data to send.
lenNumber of bytes to write.
Returns
Number of bytes written, or a negative error code on failure.

◆ ssh_client_foreach()

void ssh_client_foreach ( ssh_service_client_cb_t cb,
void * user_data )

#include <zephyr/net/ssh/common.h>

Go through all SSH client connections.

Parameters
cbUser-supplied callback function to call
user_dataUser specified data

◆ ssh_server_foreach()

void ssh_server_foreach ( ssh_service_server_cb_t cb,
void * user_data )

#include <zephyr/net/ssh/common.h>

Go through all SSH server connections.

Parameters
cbUser-supplied callback function to call
user_dataUser specified data

◆ ssh_transport_auth_password()

int ssh_transport_auth_password ( struct ssh_transport * transport,
const char * user_name,
const char * password )

#include <zephyr/net/ssh/common.h>

Authenticate an SSH transport using a password.

Parameters
transportPointer to the SSH transport.
user_nameUsername to authenticate with.
passwordPassword to authenticate with.
Returns
0 on success, or a negative error code on failure.

◆ ssh_transport_channel_open()

int ssh_transport_channel_open ( struct ssh_transport * transport,
ssh_channel_event_callback_t callback,
void * user_data )

#include <zephyr/net/ssh/common.h>

Open a new channel on an SSH transport.

Parameters
transportPointer to the SSH transport.
callbackChannel event callback for the new channel.
user_dataUser-provided context pointer passed to callback.
Returns
0 on success, or a negative error code on failure.

◆ ssh_transport_client_user_name()

const char * ssh_transport_client_user_name ( struct ssh_transport * transport)

#include <zephyr/net/ssh/common.h>

Get the authenticated client username for a transport.

Parameters
transportPointer to the SSH transport.
Returns
Pointer to the username string.