---
name: "libssh2_channel_setenv_ex"
section: "3"
platform: "linux"
package: "libssh2"
version: "1.11.1-7"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libssh2_channel_setenv_ex"
---

# libssh2\_channel\_setenv\_ex(3)

set an environment variable on the channel

## NAME

libssh2\_channel\_setenv\_ex - set an environment variable on the channel

## SYNOPSIS

```
#include <libssh2.h>
int
libssh2_channel_setenv_ex(LIBSSH2_CHANNEL *channel,
                          char *varname, unsigned int varname_len,
                          const char *value, unsigned int value_len);
int
libssh2_channel_setenv(LIBSSH2_CHANNEL *channel,
                       char *varname, const char *value);
```

## DESCRIPTION

*channel* - Previously opened channel instance such as returned by **[libssh2\_channel\_open\_ex(3)](/libssh2_channel_open_ex/3.md)**

*varname* - Name of environment variable to set on the remote channel instance.

*varname\_len* - Length of passed varname parameter.

*value* - Value to set varname to.

*value\_len* - Length of value parameter.

Set an environment variable in the remote channel's process space. Note that this does not make sense for all channel types and may be ignored by the server despite returning success.

## RETURN VALUE

Return 0 on success or negative on failure. It returns LIBSSH2\_ERROR\_EAGAIN when it would otherwise block. While LIBSSH2\_ERROR\_EAGAIN is a negative number, it is not really a failure per se.

## ERRORS

*LIBSSH2\_ERROR\_ALLOC* - An internal memory allocation call failed.

*LIBSSH2\_ERROR\_SOCKET\_SEND* - Unable to send data on socket.

*LIBSSH2\_ERROR\_CHANNEL\_REQUEST\_DENIED* -

## SEE ALSO

**[libssh2\_channel\_open\_ex(3)](/libssh2_channel_open_ex/3.md)**
