---
name: "ssh_options"
section: "3"
platform: "linux"
package: "libssh-2-doc"
version: "0.2+svn20070321-4"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/ssh_options"
---

# ssh\_options(3)

options settings for a new ssh session

## NAME

Ssh\_options - options settings for a new ssh session

### Functions

void **ssh\_options\_allow\_ssh1** (SSH\_OPTIONS \*opt, int allow)\
 *allow or deny the connection to SSH1 servers*  void **ssh\_options\_allow\_ssh2** (SSH\_OPTIONS \*opt, int allow)\
 *allow or deny the connection to SSH2 servers*  SSH\_OPTIONS \* **ssh\_options\_copy** (SSH\_OPTIONS \*opt)\
 *copies an option structure*  int **ssh\_options\_getopt** (SSH\_OPTIONS \*options, int \*argcptr, char \*\*argv)\
 *parse command line arguments*  SSH\_OPTIONS \* **ssh\_options\_new** ()\
 *initializes a new option structure*  void **ssh\_options\_set\_banner** (SSH\_OPTIONS \*opt, char \*banner)\
 *set the server banner sent to clients*  void **ssh\_options\_set\_bind** (SSH\_OPTIONS \*opt, char \*bindaddr, int port)\
 *set the local address and port binding*  void **ssh\_options\_set\_dsa\_server\_key** (SSH\_OPTIONS \*opt, char \*dsakey)\
 void **ssh\_options\_set\_fd** (SSH\_OPTIONS \*opt, int fd)\
 *set a file descriptor for connection*  void **ssh\_options\_set\_host** (SSH\_OPTIONS \*opt, const char \*hostname)\
 *set destination hostname*  void **ssh\_options\_set\_identity** (SSH\_OPTIONS \*opt, char \*identity)\
 *set the identity file name*  void **ssh\_options\_set\_known\_hosts\_file** (SSH\_OPTIONS \*opt, char \*dir)\
 *set the known hosts file name*  void **ssh\_options\_set\_port** (SSH\_OPTIONS \*opt, unsigned int port)\
 *set port to connect or to bind for a connection*  void **ssh\_options\_set\_rsa\_server\_key** (SSH\_OPTIONS \*opt, char \*rsakey)\
 void **ssh\_options\_set\_ssh\_dir** (SSH\_OPTIONS \*opt, char \*dir)\
 *set the ssh directory*  void **ssh\_options\_set\_status\_callback** (SSH\_OPTIONS \*opt, void(\*callback)(void \*arg, float status), void \*arg)\
 *set a callback to show connection status in realtime*  void **ssh\_options\_set\_timeout** (SSH\_OPTIONS \*opt, long seconds, long usec)\
 *set a timeout for the connection*  void **ssh\_options\_set\_username** (SSH\_OPTIONS \*opt, char \*username)\
 *set username for authentication*  int **ssh\_options\_set\_wanted\_algos** (SSH\_OPTIONS \*opt, int algo, char \*list)\
 *set the algorithms to be used for cryptography and compression*

## Detailed Description

options settings for a new ssh session

## Function Documentation

### void ssh\_options\_allow\_ssh1 (SSH\_OPTIONS \* opt, int allow)

allow or deny the connection to SSH1 servers

Default value is 0 (no connection to SSH1 servers)

**Parameters:**

*opt* options structure \
 *allow* nonzero values allow ssh1

### void ssh\_options\_allow\_ssh2 (SSH\_OPTIONS \* opt, int allow)

allow or deny the connection to SSH2 servers

Default value is 1 (allow connection to SSH2 servers)

**Parameters:**

*opt* options structure \
 *allow* nonzero values allow ssh2

### SSH\_OPTIONS\* ssh\_options\_copy (SSH\_OPTIONS \* opt)

copies an option structure

you may need to duplication an option structure if you make several sessions with the same options.\
\
  You cannot use twice the same option structure in ssh\_session\_connect.

**Parameters:**

*opt* option structure to copy

**Returns:**

new copied option structure

**See also:**

ssh\_session\_connect()

### int ssh\_options\_getopt (SSH\_OPTIONS \* options, int \* argcptr, char \*\* argv)

parse command line arguments

This is a helper for your application to generate the appropriate options from the command line arguments.\
\
  the argv array and argc value are changed so that parsed arguments won't appear anymore in them.\
\
  The single arguments (without switches) are not parsed. thus, myssh -u aris localhost \
\
  command won't set the hostname value of options to localhost.

**Parameters:**

*options* an empty option structure pointer \
 *argcptr* pointer to argument count \
 *argv* arguments list pointer

**Returns:**

0 on success, -1 on error

**See also:**

**ssh\_options\_new()**

### SSH\_OPTIONS\* ssh\_options\_new ()

initializes a new option structure

This structure is freed automaticaly by **ssh\_disconnect()** when you use it. \
\
  It can be used by only one **ssh\_connect()**, not more.\
\
  also by default, ssh1 support is not allowed

**Returns:**

an empty intialized option structure.

**See also:**

**ssh\_options\_getopt()**

### void ssh\_options\_set\_banner (SSH\_OPTIONS \* opt, char \* banner)

set the server banner sent to clients

**Parameters:**

*opt* options structure \
 *banner* a text banner to be shown

### void ssh\_options\_set\_bind (SSH\_OPTIONS \* opt, char \* bindaddr, int port)

set the local address and port binding

In case your client has multiple IP adresses, select the local address and port to use for the socket.\
\
  If the address or port is not bindable, it may be impossible to connect.

**Parameters:**

*opt* options structure \
 *bindaddr* bind address in form of hostname or ip address \
 *port* port number to bind

### void ssh\_options\_set\_dsa\_server\_key (SSH\_OPTIONS \* opt, char \* dsakey)

**Warning:**

I don't remember what these functions are supposed to set

### void ssh\_options\_set\_fd (SSH\_OPTIONS \* opt, int fd)

set a file descriptor for connection

If you wish to open the socket yourself for a reason or another, set the file descriptor.\
\
  don't forget to use ssh\_option\_set\_hostname() as the hostname is used as a key in the known\_host mechanism

**Parameters:**

*opt* options structure \
 *fd* an opened file descriptor to use

### void ssh\_options\_set\_host (SSH\_OPTIONS \* opt, const char \* hostname)

set destination hostname

**Parameters:**

*opt* option structure \
 *hostname* host name to connect

### void ssh\_options\_set\_identity (SSH\_OPTIONS \* opt, char \* identity)

set the identity file name

the identity file is used authenticate with public key.

**Parameters:**

*opt* options structure \
 *identity* path to the file including its name. '%s' will be substitued with the user home directory

**See also:**

ssh\_options\_set\_user\_home\_dir()

### void ssh\_options\_set\_known\_hosts\_file (SSH\_OPTIONS \* opt, char \* dir)

set the known hosts file name

the known hosts file is used to certify remote hosts are genuine.

**Parameters:**

*opt* options structure \
 *dir* path to the file including its name. '%s' will be substitued with the user home directory

**See also:**

ssh\_options\_set\_user\_home\_dir()

### void ssh\_options\_set\_port (SSH\_OPTIONS \* opt, unsigned int port)

set port to connect or to bind for a connection

**Parameters:**

*opt* options structure \
 *port* port to connect or to bind

### void ssh\_options\_set\_rsa\_server\_key (SSH\_OPTIONS \* opt, char \* rsakey)

**Warning:**

I don't remember what these functions are supposed to set

### void ssh\_options\_set\_ssh\_dir (SSH\_OPTIONS \* opt, char \* dir)

set the ssh directory

the ssh directory is used for files like known\_hosts and identity (public and private keys)\

**Parameters:**

*opt* options structure \
 *dir* directory. It may include '%s' which will be replaced by the user home directory

**See also:**

ssh\_options\_set\_user\_home\_dir()

### void ssh\_options\_set\_status\_callback (SSH\_OPTIONS \* opt, void(\*)(void \*arg, float status) callback, void \* arg)

set a callback to show connection status in realtime

During **ssh\_connect()**, libssh will call the callback with status from 0.0 to 1.0

**Parameters:**

*opt* options structure \
 *callback* a function pointer to a callback in form f(void \*userarg, float status) \
 *arg* value to be given as argument to the callback function when it is called

**See also:**

**ssh\_connect()**

### void ssh\_options\_set\_timeout (SSH\_OPTIONS \* opt, long seconds, long usec)

set a timeout for the connection

**Bug**

currently it only timeouts the socket connection, not the complete exchange

**Parameters:**

*opt* options structure \
 *seconds* number of seconds \
 *usec* number of micro seconds

### void ssh\_options\_set\_username (SSH\_OPTIONS \* opt, char \* username)

set username for authentication

**Bug**

this should not be set at options time

**Parameters:**

*opt* options structure \
 *username* user name to authenticate

### int ssh\_options\_set\_wanted\_algos (SSH\_OPTIONS \* opt, int algo, char \* list)

set the algorithms to be used for cryptography and compression

the methods are:\
\
  KEX\_HOSTKEY (server public key type) : ssh-rsa or ssh-dss\
\
  KEX\_CRYPT\_C\_S (symmetric cipher client to server)\
\
  KEX\_CRYPT\_S\_C (symmetric cipher server to client)\
\
  KEX\_COMP\_C\_S (Compression client to server): zlib or none\
\
  KEX\_COMP\_S\_C (Compression server to client): zlib or none\
\
  You don't have to use this function if using the default ciphers is okay for you\
\
  in order to enable compression client to server, do\
\
  ret=ssh\_options\_set\_wanted\_algos(opt,KEX\_COMP\_C\_S,'zlib');

**Parameters:**

*opt* options structure \
 *algo* method which needs to be changed \
 *list* list of algorithms to be used, in order of preference and separated by commas

**Returns:**

0 on success, -1 on error (most likely an algorithm is not available)
