Low-level bindings
The symbols documented on this page have all been generated automatically, along with their documentation. Most of them are pure wrappers around the C functions, but some of them also do things like return-type conversion to a Julia type (e.g. converting const char* to String).
Where possible the original documentation from the libssh headers has been included or a link generated to the upstream documentation. Note that some links may not work if the upstream documentation and this page have been generated against different versions, and some symbols in the Other section should be elsewhere.
The symbols on this page, including the auto-generated wrappers, are unsafe. Improper use may cause memory corruption (including segfaults) and weeping and gnashing of teeth. Check the upstream documentation carefully when using them, and test your code thoroughly.
LibSSH.lib.ssh_finalize — Method
ssh_finalize()LibSSH.lib.ssh_init — Method
ssh_init()LibSSH.lib.SSH_AGAIN — Constant
Value returned when the function is in non-blocking mode and must be called again.
LibSSH.lib.SSH_AUTH_METHOD_GSSAPI_MIC — Constant
Auth method enum (upstream documentation).
LibSSH.lib.SSH_AUTH_METHOD_HOSTBASED — Constant
Auth method enum (upstream documentation).
LibSSH.lib.SSH_AUTH_METHOD_INTERACTIVE — Constant
Auth method enum (upstream documentation).
LibSSH.lib.SSH_AUTH_METHOD_NONE — Constant
Auth method enum (upstream documentation).
LibSSH.lib.SSH_AUTH_METHOD_PASSWORD — Constant
Auth method enum (upstream documentation).
LibSSH.lib.SSH_AUTH_METHOD_PUBLICKEY — Constant
Auth method enum (upstream documentation).
LibSSH.lib.SSH_AUTH_METHOD_UNKNOWN — Constant
Auth method enum (upstream documentation).
LibSSH.lib.SSH_ERROR — Constant
Value returned if an error occurred.
LibSSH.lib.SSH_OK — Constant
Value returned on success.
Authentication
LibSSH.lib.ssh_set_agent_channel — Method
ssh_set_agent_channel(session, channel)LibSSH.lib.ssh_set_agent_socket — Method
ssh_set_agent_socket(session, fd)LibSSH.lib.ssh_userauth_agent — Method
ssh_userauth_agent(session, username)LibSSH.lib.ssh_userauth_gssapi — Method
ssh_userauth_gssapi(session)LibSSH.lib.ssh_userauth_kbdint — Method
ssh_userauth_kbdint(session, user, submethods)LibSSH.lib.ssh_userauth_kbdint_getanswer — Method
ssh_userauth_kbdint_getanswer(session, i; throw = true)Auto-generated wrapper around ssh_userauth_kbdint_getanswer().
LibSSH.lib.ssh_userauth_kbdint_getinstruction — Method
ssh_userauth_kbdint_getinstruction(session)LibSSH.lib.ssh_userauth_kbdint_getname — Method
ssh_userauth_kbdint_getname(session; throw = true)Auto-generated wrapper around ssh_userauth_kbdint_getname().
LibSSH.lib.ssh_userauth_kbdint_getnanswers — Method
ssh_userauth_kbdint_getnanswers(session)LibSSH.lib.ssh_userauth_kbdint_getnprompts — Method
ssh_userauth_kbdint_getnprompts(session)LibSSH.lib.ssh_userauth_kbdint_getprompt — Method
ssh_userauth_kbdint_getprompt(session, i, echo; throw = true)Auto-generated wrapper around ssh_userauth_kbdint_getprompt().
LibSSH.lib.ssh_userauth_kbdint_setanswer — Method
ssh_userauth_kbdint_setanswer(session, i, answer)LibSSH.lib.ssh_userauth_list — Method
ssh_userauth_list(session, username)LibSSH.lib.ssh_userauth_none — Method
ssh_userauth_none(session, username)LibSSH.lib.ssh_userauth_password — Method
ssh_userauth_password(session, username, password)LibSSH.lib.ssh_userauth_publickey — Method
ssh_userauth_publickey(session, username, privkey)LibSSH.lib.ssh_userauth_publickey_auto — Method
ssh_userauth_publickey_auto(session, username, passphrase)LibSSH.lib.ssh_userauth_publickey_auto_get_current_identity — Method
ssh_userauth_publickey_auto_get_current_identity(session, value)LibSSH.lib.ssh_userauth_try_publickey — Method
ssh_userauth_try_publickey(session, username, pubkey)Buffers
LibSSH.lib.ssh_buffer_add_data — Method
ssh_buffer_add_data(buffer, data, len)LibSSH.lib.ssh_buffer_free — Method
ssh_buffer_free(buffer)LibSSH.lib.ssh_buffer_get — Method
ssh_buffer_get(buffer)LibSSH.lib.ssh_buffer_get_data — Method
ssh_buffer_get_data(buffer, data, requestedlen)LibSSH.lib.ssh_buffer_get_len — Method
ssh_buffer_get_len(buffer)LibSSH.lib.ssh_buffer_new — Method
ssh_buffer_new()LibSSH.lib.ssh_buffer_reinit — Method
ssh_buffer_reinit(buffer)Callbacks
LibSSH.lib.ssh_add_channel_callbacks — Method
ssh_add_channel_callbacks(channel, cb)Add channel callback functions
This function will add channel callback functions to the channel callback list. Callbacks missing from a callback structure will be probed in the next on the list.
Arguments
channel: The channel to set the callback structure.cb: The callback structure itself.
Returns
SSH_OK on success, SSH_ERROR on error.
See also
LibSSH.lib.ssh_remove_channel_callbacks — Method
ssh_remove_channel_callbacks(channel, cb)Remove a channel callback.
The channel has been added with ssh_add_channel_callbacks or ssh_set_channel_callbacks in this case.
Arguments
channel: The channel to remove the callback structure from.cb: The callback structure to remove
Returns
LibSSH.lib.ssh_set_callbacks — Method
ssh_set_callbacks(session, cb)Set the session callback functions.
This functions sets the callback structure to use your own callback functions for auth, logging and status.
Note, that the callback structure is not copied into the session so it needs to be valid for the whole session lifetime.
struct ssh_callbacks_struct cb = {
.userdata = data,
.auth_function = my_auth_function
};
ssh_callbacks_init(&cb);
ssh_set_callbacks(session, &cb);Arguments
session: The session to set the callback structure.cb: The callback structure itself.
Returns
LibSSH.lib.ssh_set_channel_callbacks — Method
ssh_set_channel_callbacks(channel, cb)Set the channel callback functions.
This functions sets the callback structure to use your own callback functions for channel data and exceptions.
Note, that the structure is not copied to the channel structure so it needs to be valid as for the whole life of the channel or until it is removed with ssh_remove_channel_callbacks().
struct ssh_channel_callbacks_struct cb = {
.userdata = data,
.channel_data_function = my_channel_data_function
};
ssh_callbacks_init(&cb);
ssh_set_channel_callbacks(channel, &cb);Arguments
channel: The channel to set the callback structure.cb: The callback structure itself.
Returns
LibSSH.lib.ssh_set_server_callbacks — Method
ssh_set_server_callbacks(session, cb)Set the session server callback functions.
This functions sets the callback structure to use your own callback functions for user authentication, new channels and requests.
Note, that the structure is not copied to the session structure so it needs to be valid for the whole session lifetime.
struct ssh_server_callbacks_struct cb = {
.userdata = data,
.auth_password_function = my_auth_function
};
ssh_callbacks_init(&cb);
ssh_set_server_callbacks(session, &cb);Arguments
session: The session to set the callback structure.cb: The callback structure itself.
Returns
Channel
LibSSH.lib.channel_read_buffer — Method
channel_read_buffer(channel, buffer, count, is_stderr)LibSSH.lib.ssh_channel_accept_forward — Method
ssh_channel_accept_forward(session, timeout_ms, destination_port)LibSSH.lib.ssh_channel_accept_x11 — Method
ssh_channel_accept_x11(channel, timeout_ms)LibSSH.lib.ssh_channel_cancel_forward — Method
ssh_channel_cancel_forward(session, address, port)LibSSH.lib.ssh_channel_change_pty_size — Method
ssh_channel_change_pty_size(channel, cols, rows)LibSSH.lib.ssh_channel_close — Method
ssh_channel_close(channel)LibSSH.lib.ssh_channel_free — Method
ssh_channel_free(channel)LibSSH.lib.ssh_channel_get_exit_state — Method
ssh_channel_get_exit_state(channel, pexit_code, pexit_signal, pcore_dumped)LibSSH.lib.ssh_channel_get_exit_status — Method
ssh_channel_get_exit_status(channel)LibSSH.lib.ssh_channel_get_session — Method
ssh_channel_get_session(channel)LibSSH.lib.ssh_channel_is_closed — Method
ssh_channel_is_closed(channel)LibSSH.lib.ssh_channel_is_eof — Method
ssh_channel_is_eof(channel)LibSSH.lib.ssh_channel_is_open — Method
ssh_channel_is_open(channel)LibSSH.lib.ssh_channel_listen_forward — Method
ssh_channel_listen_forward(session, address, port, bound_port)LibSSH.lib.ssh_channel_new — Method
ssh_channel_new(session)LibSSH.lib.ssh_channel_open_auth_agent — Method
ssh_channel_open_auth_agent(channel)LibSSH.lib.ssh_channel_open_forward — Method
ssh_channel_open_forward(channel, remotehost, remoteport, sourcehost, localport)LibSSH.lib.ssh_channel_open_forward_port — Method
ssh_channel_open_forward_port(session, timeout_ms, destination_port, originator, originator_port)LibSSH.lib.ssh_channel_open_forward_unix — Method
ssh_channel_open_forward_unix(channel, remotepath, sourcehost, localport)LibSSH.lib.ssh_channel_open_reverse_forward — Method
ssh_channel_open_reverse_forward(channel, remotehost, remoteport, sourcehost, localport)LibSSH.lib.ssh_channel_open_session — Method
ssh_channel_open_session(channel)LibSSH.lib.ssh_channel_open_x11 — Method
ssh_channel_open_x11(channel, orig_addr, orig_port)LibSSH.lib.ssh_channel_poll — Method
ssh_channel_poll(channel, is_stderr)LibSSH.lib.ssh_channel_poll_timeout — Method
ssh_channel_poll_timeout(channel, timeout, is_stderr)LibSSH.lib.ssh_channel_read — Method
ssh_channel_read(channel, dest, count, is_stderr)LibSSH.lib.ssh_channel_read_nonblocking — Method
ssh_channel_read_nonblocking(channel, dest, count, is_stderr)LibSSH.lib.ssh_channel_read_timeout — Method
ssh_channel_read_timeout(channel, dest, count, is_stderr, timeout_ms)LibSSH.lib.ssh_channel_request_auth_agent — Method
ssh_channel_request_auth_agent(channel)LibSSH.lib.ssh_channel_request_env — Method
ssh_channel_request_env(channel, name, value)LibSSH.lib.ssh_channel_request_exec — Method
ssh_channel_request_exec(channel, cmd)LibSSH.lib.ssh_channel_request_pty — Method
ssh_channel_request_pty(channel)LibSSH.lib.ssh_channel_request_pty_size_modes — Method
ssh_channel_request_pty_size_modes(channel, term, cols, rows, modes, modes_len)LibSSH.lib.ssh_channel_request_send_break — Method
ssh_channel_request_send_break(channel, length)LibSSH.lib.ssh_channel_request_send_exit_signal — Method
ssh_channel_request_send_exit_signal(channel, signum, core, errmsg, lang)LibSSH.lib.ssh_channel_request_send_exit_status — Method
ssh_channel_request_send_exit_status(channel, exit_status)LibSSH.lib.ssh_channel_request_send_signal — Method
ssh_channel_request_send_signal(channel, signum)LibSSH.lib.ssh_channel_request_sftp — Method
ssh_channel_request_sftp(channel)LibSSH.lib.ssh_channel_request_shell — Method
ssh_channel_request_shell(channel)LibSSH.lib.ssh_channel_request_subsystem — Method
ssh_channel_request_subsystem(channel, subsystem)LibSSH.lib.ssh_channel_request_x11 — Method
ssh_channel_request_x11(channel, single_connection, protocol, cookie, screen_number)LibSSH.lib.ssh_channel_select — Method
ssh_channel_select(readchans, writechans, exceptchans, timeout)LibSSH.lib.ssh_channel_send_eof — Method
ssh_channel_send_eof(channel)LibSSH.lib.ssh_channel_set_blocking — Method
ssh_channel_set_blocking(channel, blocking)LibSSH.lib.ssh_channel_set_counter — Method
ssh_channel_set_counter(channel, counter)LibSSH.lib.ssh_channel_window_size — Method
ssh_channel_window_size(channel)LibSSH.lib.ssh_channel_write — Method
ssh_channel_write(channel, data, len)LibSSH.lib.ssh_channel_write_stderr — Method
ssh_channel_write_stderr(channel, data, len)Errors
LibSSH.lib.ssh_get_error — Method
ssh_get_error(error)LibSSH.lib.ssh_get_error_code — Method
ssh_get_error_code(error)Helpers
LibSSH.lib.ssh_basename — Method
ssh_basename(path)LibSSH.lib.ssh_dirname — Method
ssh_dirname(path)LibSSH.lib.ssh_get_hexa — Method
ssh_get_hexa(what, len)LibSSH.lib.ssh_get_random — Method
ssh_get_random(where, len, strong)LibSSH.lib.ssh_getpass — Method
ssh_getpass(prompt, buf, len, echo, verify)LibSSH.lib.ssh_mkdir — Method
ssh_mkdir(pathname, mode)LibSSH.lib.ssh_print_hexa — Method
ssh_print_hexa(descr, what, len)LibSSH.lib.ssh_version — Method
ssh_version(req_version)Logging
LibSSH.lib.ssh_get_log_callback — Method
ssh_get_log_callback()Get the pointer to the logging callback function.
Returns
The pointer the the callback or NULL if none set.
LibSSH.lib.ssh_get_log_level — Method
ssh_get_log_level()LibSSH.lib.ssh_get_log_userdata — Method
ssh_get_log_userdata()LibSSH.lib.ssh_set_log_callback — Method
ssh_set_log_callback(cb)Set the logging callback function.
Arguments
cb:[in] The callback to set.
Returns
0 on success, < 0 on error.
LibSSH.lib.ssh_set_log_level — Method
ssh_set_log_level(level)LibSSH.lib.ssh_set_log_userdata — Method
ssh_set_log_userdata(data)Message
LibSSH.lib.ssh_message_free — Method
ssh_message_free(msg)LibSSH.lib.ssh_message_get — Method
ssh_message_get(session)LibSSH.lib.ssh_message_subtype — Method
ssh_message_subtype(msg)LibSSH.lib.ssh_message_type — Method
ssh_message_type(msg)Polling
LibSSH.lib.ssh_event_add_connector — Method
ssh_event_add_connector(event, connector)LibSSH.lib.ssh_event_add_fd — Method
ssh_event_add_fd(event, fd, events, cb, userdata)LibSSH.lib.ssh_event_add_session — Method
ssh_event_add_session(event, session)LibSSH.lib.ssh_event_dopoll — Method
ssh_event_dopoll(event, timeout)LibSSH.lib.ssh_event_free — Method
ssh_event_free(event)LibSSH.lib.ssh_event_new — Method
ssh_event_new()LibSSH.lib.ssh_event_remove_connector — Method
ssh_event_remove_connector(event, connector)LibSSH.lib.ssh_event_remove_fd — Method
ssh_event_remove_fd(event, fd)LibSSH.lib.ssh_event_remove_session — Method
ssh_event_remove_session(event, session)Public/private keys
LibSSH.lib.ssh_key_cmp — Method
ssh_key_cmp(k1, k2, what)LibSSH.lib.ssh_key_dup — Method
ssh_key_dup(key)LibSSH.lib.ssh_key_free — Method
ssh_key_free(key)LibSSH.lib.ssh_key_is_private — Method
ssh_key_is_private(k)LibSSH.lib.ssh_key_is_public — Method
ssh_key_is_public(k)LibSSH.lib.ssh_key_new — Method
ssh_key_new()LibSSH.lib.ssh_key_type — Method
ssh_key_type(key)LibSSH.lib.ssh_key_type_from_name — Method
ssh_key_type_from_name(name)LibSSH.lib.ssh_key_type_to_char — Method
ssh_key_type_to_char(type)LibSSH.lib.ssh_pki_copy_cert_to_privkey — Method
ssh_pki_copy_cert_to_privkey(cert_key, privkey)LibSSH.lib.ssh_pki_export_privkey_base64 — Method
ssh_pki_export_privkey_base64(privkey, passphrase, auth_fn, auth_data, b64_key)LibSSH.lib.ssh_pki_export_privkey_base64_format — Method
ssh_pki_export_privkey_base64_format(privkey, passphrase, auth_fn, auth_data, b64_key, format)LibSSH.lib.ssh_pki_export_privkey_file — Method
ssh_pki_export_privkey_file(privkey, passphrase, auth_fn, auth_data, filename)LibSSH.lib.ssh_pki_export_privkey_file_format — Method
ssh_pki_export_privkey_file_format(privkey, passphrase, auth_fn, auth_data, filename, format)LibSSH.lib.ssh_pki_export_privkey_to_pubkey — Method
ssh_pki_export_privkey_to_pubkey(privkey, pkey)LibSSH.lib.ssh_pki_export_pubkey_base64 — Method
ssh_pki_export_pubkey_base64(key, b64_key)LibSSH.lib.ssh_pki_export_pubkey_file — Method
ssh_pki_export_pubkey_file(key, filename)LibSSH.lib.ssh_pki_generate — Method
ssh_pki_generate(type, parameter, pkey)LibSSH.lib.ssh_pki_import_cert_base64 — Method
ssh_pki_import_cert_base64(b64_cert, type, pkey)LibSSH.lib.ssh_pki_import_cert_file — Method
ssh_pki_import_cert_file(filename, pkey)LibSSH.lib.ssh_pki_import_privkey_base64 — Method
ssh_pki_import_privkey_base64(b64_key, passphrase, auth_fn, auth_data, pkey)LibSSH.lib.ssh_pki_import_privkey_file — Method
ssh_pki_import_privkey_file(filename, passphrase, auth_fn, auth_data, pkey)LibSSH.lib.ssh_pki_import_pubkey_base64 — Method
ssh_pki_import_pubkey_base64(b64_key, type, pkey)LibSSH.lib.ssh_pki_import_pubkey_file — Method
ssh_pki_import_pubkey_file(filename, pkey)LibSSH.lib.ssh_pki_key_ecdsa_name — Method
ssh_pki_key_ecdsa_name(key)Server
LibSSH.lib.ssh_bind_accept — Method
ssh_bind_accept(ssh_bind_o, session)Accept an incoming ssh connection and initialize the session.
Arguments
ssh_bind_o: The ssh server bind to accept a connection.session: A preallocated ssh session
Returns
SSH_OK when a connection is established
See also
LibSSH.lib.ssh_bind_accept_fd — Method
ssh_bind_accept_fd(ssh_bind_o, session, fd)Accept an incoming ssh connection on the given file descriptor and initialize the session.
Arguments
ssh_bind_o: The ssh server bind to accept a connection.session: A preallocated ssh sessionfd: A file descriptor of an already established TCP inbound connection
Returns
SSH_OK when a connection is established
See also
LibSSH.lib.ssh_bind_fd_toaccept — Method
ssh_bind_fd_toaccept(ssh_bind_o)Allow the file descriptor to accept new sessions.
Arguments
ssh_bind_o: The ssh server bind to use.
LibSSH.lib.ssh_bind_free — Method
ssh_bind_free(ssh_bind_o)Free a ssh servers bind.
Note that this will also free options that have been set on the bind, including keys set with SSH_BIND_OPTIONS_IMPORT_KEY.
Arguments
ssh_bind_o: The ssh server bind to free.
LibSSH.lib.ssh_bind_get_fd — Method
ssh_bind_get_fd(ssh_bind_o)Recover the file descriptor from the session.
Arguments
ssh_bind_o: The ssh server bind to get the fd from.
Returns
The file descriptor.
LibSSH.lib.ssh_bind_listen — Method
ssh_bind_listen(ssh_bind_o)Start listening to the socket.
Arguments
ssh_bind_o: The ssh server bind to use.
Returns
0 on success, < 0 on error.
LibSSH.lib.ssh_bind_new — Method
LibSSH.lib.ssh_bind_options_parse_config — Method
ssh_bind_options_parse_config(sshbind, filename)LibSSH.lib.ssh_bind_options_set — Method
ssh_bind_options_set(sshbind, type, value)LibSSH.lib.ssh_bind_set_blocking — Method
ssh_bind_set_blocking(ssh_bind_o, blocking)Set the session to blocking/nonblocking mode.
Arguments
ssh_bind_o: The ssh server bind to use.blocking: Zero for nonblocking mode.
LibSSH.lib.ssh_bind_set_callbacks — Method
ssh_bind_set_callbacks(sshbind, callbacks, userdata)Set the callback for this bind.
struct ssh_callbacks_struct cb = {
.userdata = data,
.auth_function = my_auth_function
};
ssh_callbacks_init(&cb);
ssh_bind_set_callbacks(session, &cb);Arguments
sshbind:[in] The bind to set the callback on.callbacks:[in] An already set upssh_bind_callbacksinstance.userdata:[in] A pointer to private data to pass to the callbacks.
Returns
LibSSH.lib.ssh_bind_set_fd — Method
ssh_bind_set_fd(ssh_bind_o, fd)Set the file descriptor for a session.
Arguments
ssh_bind_o: The ssh server bind to set the fd.fd: The file descriptssh_bind B
LibSSH.lib.ssh_gssapi_get_creds — Method
ssh_gssapi_get_creds(session)LibSSH.lib.ssh_handle_key_exchange — Method
ssh_handle_key_exchange(session)Handles the key exchange and set up encryption
Arguments
session: A connected ssh session
Returns
SSH_OK if the key exchange was successful
See also
LibSSH.lib.ssh_message_auth_kbdint_is_response — Method
ssh_message_auth_kbdint_is_response(msg)Auto-generated wrapper around ssh_message_auth_kbdint_is_response().
LibSSH.lib.ssh_message_auth_password — Method
ssh_message_auth_password(msg; throw = true)Auto-generated wrapper around ssh_message_auth_password(). Original upstream documentation is below.
Get the password of the authenticated user.
This function should not be used anymore as there is a callback based server implementation now auth_password_function.
Arguments
msg:[in] The message to get the password from.
Returns
The password or NULL if an error occurred.
See also
LibSSH.lib.ssh_message_auth_pubkey — Method
ssh_message_auth_pubkey(msg)Get the publickey of the authenticated user.
If you need the key for later user you should duplicate it.
This function should not be used anymore as there is a callback based server implementation auth_pubkey_function.
Arguments
msg:[in] The message to get the public key from.
Returns
The public key or NULL.
See also
ssh_key_dup(), ssh_key_cmp(), ssh_message_get(), ssh_message_type()
LibSSH.lib.ssh_message_auth_publickey_state — Method
ssh_message_auth_publickey_state(msg)This function should not be used anymore as there is a callback based server implementation auth_pubkey_function
Arguments
msg:[in] The message to get the public key state from.
LibSSH.lib.ssh_message_auth_reply_pk_ok — Method
ssh_message_auth_reply_pk_ok(msg, algo, pubkey)LibSSH.lib.ssh_message_auth_reply_pk_ok_simple — Method
ssh_message_auth_reply_pk_ok_simple(msg)LibSSH.lib.ssh_message_auth_set_methods — Method
ssh_message_auth_set_methods(msg, methods; throw = true)Auto-generated wrapper around ssh_message_auth_set_methods().
LibSSH.lib.ssh_message_auth_user — Method
ssh_message_auth_user(msg; throw = true)Auto-generated wrapper around ssh_message_auth_user(). Original upstream documentation is below.
Get the name of the authenticated user.
Arguments
msg:[in] The message to get the username from.
Returns
The username or NULL if an error occurred.
See also
LibSSH.lib.ssh_message_global_request_reply_success — Method
ssh_message_global_request_reply_success(msg, bound_port)LibSSH.lib.ssh_message_reply_default — Method
ssh_message_reply_default(msg; throw = true)Auto-generated wrapper around ssh_message_reply_default(). Original upstream documentation is below.
Reply with a standard reject message.
Use this function if you don't know what to respond or if you want to reject a request.
Arguments
msg:[in] The message to use for the reply.
Returns
0 on success, -1 on error.
See also
LibSSH.lib.ssh_message_service_reply_success — Method
ssh_message_service_reply_success(msg)LibSSH.lib.ssh_message_service_service — Method
ssh_message_service_service(msg)LibSSH.lib.ssh_send_issue_banner — Method
ssh_send_issue_banner(session, banner)Send the server's issue-banner to client.
Arguments
session:[in] The server session.banner:[in] The server's banner.
Returns
LibSSH.lib.ssh_send_keepalive — Method
ssh_send_keepalive(session)LibSSH.lib.ssh_server_init_kex — Method
ssh_server_init_kex(session)Initialize the set of key exchange, hostkey, ciphers, MACs, and compression algorithms for the given ssh_session.
The selection of algorithms and keys used are determined by the options that are currently set in the given ssh_session structure. May only be called before the initial key exchange has begun.
Arguments
session: The session structure to initialize.
Returns
SSH_OK if initialization succeeds.
See also
LibSSH.lib.ssh_set_auth_methods — Method
ssh_set_auth_methods(session, auth_methods)Set the acceptable authentication methods to be sent to the client.
Supported methods are:
SSH_AUTH_METHOD_PASSWORD SSH_AUTH_METHOD_PUBLICKEY SSH_AUTH_METHOD_HOSTBASED SSH_AUTH_METHOD_INTERACTIVE SSH_AUTH_METHOD_GSSAPI_MIC
Arguments
session:[in] The server sessionauth_methods:[in] The authentication methods we will support, which can be bitwise-or'd.
LibSSH.lib.ssh_set_message_callback — Method
ssh_set_message_callback(session, ssh_bind_message_callback, data)Session
LibSSH.lib.ssh_blocking_flush — Method
ssh_blocking_flush(session, timeout)LibSSH.lib.ssh_clean_pubkey_hash — Method
ssh_clean_pubkey_hash(hash)LibSSH.lib.ssh_connect — Method
ssh_connect(session)LibSSH.lib.ssh_copyright — Method
ssh_copyright()LibSSH.lib.ssh_disconnect — Method
ssh_disconnect(session)LibSSH.lib.ssh_dump_knownhost — Method
ssh_dump_knownhost(session)LibSSH.lib.ssh_free — Method
ssh_free(session)LibSSH.lib.ssh_get_cipher_in — Method
ssh_get_cipher_in(session)LibSSH.lib.ssh_get_cipher_out — Method
ssh_get_cipher_out(session)LibSSH.lib.ssh_get_clientbanner — Method
ssh_get_clientbanner(session)LibSSH.lib.ssh_get_disconnect_message — Method
ssh_get_disconnect_message(session)LibSSH.lib.ssh_get_fd — Method
ssh_get_fd(session)LibSSH.lib.ssh_get_fingerprint_hash — Method
ssh_get_fingerprint_hash(type, hash, len)LibSSH.lib.ssh_get_hmac_in — Method
ssh_get_hmac_in(session)LibSSH.lib.ssh_get_hmac_out — Method
ssh_get_hmac_out(session)LibSSH.lib.ssh_get_issue_banner — Method
ssh_get_issue_banner(session)LibSSH.lib.ssh_get_kex_algo — Method
ssh_get_kex_algo(session)LibSSH.lib.ssh_get_openssh_version — Method
ssh_get_openssh_version(session)LibSSH.lib.ssh_get_poll_flags — Method
ssh_get_poll_flags(session)LibSSH.lib.ssh_get_pubkey_hash — Method
ssh_get_pubkey_hash(session, hash)LibSSH.lib.ssh_get_publickey — Method
ssh_get_publickey(session, key)LibSSH.lib.ssh_get_publickey_hash — Method
ssh_get_publickey_hash(key, type, hash, hlen)LibSSH.lib.ssh_get_server_publickey — Method
ssh_get_server_publickey(session, key)LibSSH.lib.ssh_get_serverbanner — Method
ssh_get_serverbanner(session)LibSSH.lib.ssh_get_status — Method
ssh_get_status(session)LibSSH.lib.ssh_get_version — Method
ssh_get_version(session)LibSSH.lib.ssh_is_blocking — Method
ssh_is_blocking(session)LibSSH.lib.ssh_is_connected — Method
ssh_is_connected(session)LibSSH.lib.ssh_is_server_known — Method
ssh_is_server_known(session)LibSSH.lib.ssh_known_hosts_parse_line — Method
ssh_known_hosts_parse_line(host, line, entry)LibSSH.lib.ssh_knownhosts_entry_free — Method
ssh_knownhosts_entry_free(entry)LibSSH.lib.ssh_new — Method
ssh_new()LibSSH.lib.ssh_options_copy — Method
ssh_options_copy(src, dest)LibSSH.lib.ssh_options_get — Method
ssh_options_get(session, type, value; throw = true)Auto-generated wrapper around ssh_options_get().
LibSSH.lib.ssh_options_get_port — Method
ssh_options_get_port(session, port_target; throw = true)Auto-generated wrapper around ssh_options_get_port().
LibSSH.lib.ssh_options_getopt — Method
ssh_options_getopt(session, argcptr, argv)LibSSH.lib.ssh_options_parse_config — Method
ssh_options_parse_config(session, filename)LibSSH.lib.ssh_options_set — Method
ssh_options_set(session, type, value; throw = true)Auto-generated wrapper around ssh_options_set().
LibSSH.lib.ssh_print_hash — Method
ssh_print_hash(type, hash, len)LibSSH.lib.ssh_request_no_more_sessions — Method
ssh_request_no_more_sessions(session)LibSSH.lib.ssh_select — Method
ssh_select(channels, outchannels, maxfd, readfds, timeout)LibSSH.lib.ssh_send_debug — Method
ssh_send_debug(session, message, always_display)LibSSH.lib.ssh_send_ignore — Method
ssh_send_ignore(session, data)LibSSH.lib.ssh_session_export_known_hosts_entry — Method
ssh_session_export_known_hosts_entry(session, pentry_string)LibSSH.lib.ssh_session_get_known_hosts_entry — Method
ssh_session_get_known_hosts_entry(session, pentry)LibSSH.lib.ssh_session_has_known_hosts_entry — Method
ssh_session_has_known_hosts_entry(session)LibSSH.lib.ssh_session_is_known_server — Method
ssh_session_is_known_server(session)LibSSH.lib.ssh_session_set_disconnect_message — Method
ssh_session_set_disconnect_message(session, message)LibSSH.lib.ssh_session_update_known_hosts — Method
ssh_session_update_known_hosts(session)LibSSH.lib.ssh_set_blocking — Method
ssh_set_blocking(session, blocking)LibSSH.lib.ssh_set_counters — Method
ssh_set_counters(session, scounter, rcounter)LibSSH.lib.ssh_set_fd_except — Method
ssh_set_fd_except(session)LibSSH.lib.ssh_set_fd_toread — Method
ssh_set_fd_toread(session)LibSSH.lib.ssh_set_fd_towrite — Method
ssh_set_fd_towrite(session)LibSSH.lib.ssh_silent_disconnect — Method
ssh_silent_disconnect(session)LibSSH.lib.ssh_write_knownhost — Method
ssh_write_knownhost(session)Strings
LibSSH.lib.ssh_string_burn — Method
ssh_string_burn(str)LibSSH.lib.ssh_string_copy — Method
ssh_string_copy(str)LibSSH.lib.ssh_string_data — Method
ssh_string_data(str)LibSSH.lib.ssh_string_fill — Method
ssh_string_fill(str, data, len)LibSSH.lib.ssh_string_free — Method
ssh_string_free(str)LibSSH.lib.ssh_string_free_char — Method
ssh_string_free_char(s)LibSSH.lib.ssh_string_from_char — Method
ssh_string_from_char(what)LibSSH.lib.ssh_string_get_char — Method
ssh_string_get_char(str)LibSSH.lib.ssh_string_len — Method
ssh_string_len(str)LibSSH.lib.ssh_string_new — Method
ssh_string_new(size)LibSSH.lib.ssh_string_to_char — Method
ssh_string_to_char(str)SCP
LibSSH.lib.ssh_scp_accept_request — Method
ssh_scp_accept_request(scp)LibSSH.lib.ssh_scp_close — Method
ssh_scp_close(scp)LibSSH.lib.ssh_scp_deny_request — Method
ssh_scp_deny_request(scp, reason)LibSSH.lib.ssh_scp_free — Method
ssh_scp_free(scp)LibSSH.lib.ssh_scp_init — Method
ssh_scp_init(scp)LibSSH.lib.ssh_scp_leave_directory — Method
ssh_scp_leave_directory(scp)LibSSH.lib.ssh_scp_new — Method
ssh_scp_new(session, mode, location)LibSSH.lib.ssh_scp_pull_request — Method
ssh_scp_pull_request(scp)LibSSH.lib.ssh_scp_push_directory — Method
ssh_scp_push_directory(scp, dirname, mode)LibSSH.lib.ssh_scp_push_file — Method
ssh_scp_push_file(scp, filename, size, perms)LibSSH.lib.ssh_scp_push_file64 — Method
ssh_scp_push_file64(scp, filename, size, perms)LibSSH.lib.ssh_scp_read — Method
ssh_scp_read(scp, buffer, size)LibSSH.lib.ssh_scp_request_get_filename — Method
ssh_scp_request_get_filename(scp)LibSSH.lib.ssh_scp_request_get_permissions — Method
ssh_scp_request_get_permissions(scp)LibSSH.lib.ssh_scp_request_get_size — Method
ssh_scp_request_get_size(scp)LibSSH.lib.ssh_scp_request_get_size64 — Method
ssh_scp_request_get_size64(scp)LibSSH.lib.ssh_scp_request_get_warning — Method
ssh_scp_request_get_warning(scp)LibSSH.lib.ssh_scp_write — Method
ssh_scp_write(scp, buffer, len)SFTP
LibSSH.lib.sftp_aio_begin_read — Method
sftp_aio_begin_read(file, len, aio)Start an asynchronous read from a file using an opened sftp file handle.
Its goal is to avoid the slowdowns related to the request/response pattern of a synchronous read. To do so, you must call 2 functions :
sftp_aio_begin_read() and sftp_aio_wait_read().
The first step is to call
sftp_aio_begin_read(). This function sends a read request to the sftp server, dynamically allocates memory to store information about the sent request and provides the caller an sftp aio handle to that memory.The second step is to call
sftp_aio_wait_read() and pass it the address of a location storing the sftp aio handle provided bysftp_aio_begin_read().
These two functions do not close the open sftp file handle passed to sftp_aio_begin_read() irrespective of whether they fail or not.
It is the responsibility of the caller to ensure that the open sftp file handle passed to sftp_aio_begin_read() must not be closed before the corresponding call to sftp_aio_wait_read(). After sftp_aio_wait_read() returns, it is caller's decision whether to immediately close the file by calling sftp_close() or to keep it open and perform some more operations on it.
This function caps the length a user is allowed to read from an sftp file, the value of len parameter after capping is returned on success.
The value used for the cap is same as the value of the max_read_length field of the sftp_limits_t returned by sftp_limits().
When calling this function, the internal file offset is updated corresponding to the number of bytes requested to read.
A call to sftp_aio_begin_read() sends a request to the server. When the server answers, libssh allocates memory to store it until sftp_aio_wait_read() is called. Not calling sftp_aio_wait_read() will lead to memory leaks.
Arguments
file: The opened sftp file handle to be read from.len: Number of bytes to read.aio: Pointer to a location where the sftp aio handle (corresponding to the sent request) should be stored.
Returns
On success, the number of bytes the server is requested to read (value of len parameter after capping). On error, SSH_ERROR with sftp and ssh errors set.
See also
sftp_aio_wait_read(), sftp_aio_free(), sftp_open(), sftp_close(), sftp_get_error(), ssh_get_error()
LibSSH.lib.sftp_aio_begin_write — Method
sftp_aio_begin_write(file, buf, len, aio)Start an asynchronous write to a file using an opened sftp file handle.
Its goal is to avoid the slowdowns related to the request/response pattern of a synchronous write. To do so, you must call 2 functions :
sftp_aio_begin_write() and sftp_aio_wait_write().
The first step is to call
sftp_aio_begin_write(). This function sends a write request to the sftp server, dynamically allocates memory to store information about the sent request and provides the caller an sftp aio handle to that memory.The second step is to call
sftp_aio_wait_write() and pass it the address of a location storing the sftp aio handle provided bysftp_aio_begin_write().
These two functions do not close the open sftp file handle passed to sftp_aio_begin_write() irrespective of whether they fail or not.
It is the responsibility of the caller to ensure that the open sftp file handle passed to sftp_aio_begin_write() must not be closed before the corresponding call to sftp_aio_wait_write(). After sftp_aio_wait_write() returns, it is caller's decision whether to immediately close the file by calling sftp_close() or to keep it open and perform some more operations on it.
This function caps the length a user is allowed to write to an sftp file, the value of len parameter after capping is returned on success.
The value used for the cap is same as the value of the max_write_length field of the sftp_limits_t returned by sftp_limits().
When calling this function, the internal file offset is updated corresponding to the number of bytes requested to write.
A call to sftp_aio_begin_write() sends a request to the server. When the server answers, libssh allocates memory to store it until sftp_aio_wait_write() is called. Not calling sftp_aio_wait_write() will lead to memory leaks.
Arguments
file: The opened sftp file handle to write to.buf: Pointer to the buffer containing data to write.len: Number of bytes to write.aio: Pointer to a location where the sftp aio handle (corresponding to the sent request) should be stored.
Returns
On success, the number of bytes the server is requested to write (value of len parameter after capping). On error, SSH_ERROR with sftp and ssh errors set.
See also
sftp_aio_wait_write(), sftp_aio_free(), sftp_open(), sftp_close(), sftp_get_error(), ssh_get_error()
LibSSH.lib.sftp_aio_free — Method
sftp_aio_free(aio)Deallocate memory corresponding to a sftp aio handle.
This function deallocates memory corresponding to the aio handle returned by the sftp_aio_begin_*() functions. Users can use this function to free memory corresponding to an aio handle for an outstanding async i/o request on encountering some error.
Arguments
aio: sftp aio handle corresponding to which memory has to be deallocated.
See also
sftp_aio_begin_read(), sftp_aio_wait_read(), sftp_aio_begin_write(), sftp_aio_wait_write()
LibSSH.lib.sftp_aio_wait_read — Method
sftp_aio_wait_read(aio::Ptr{sftp_aio}, buf::Ptr{Cvoid}, buf_size::Csize_t)Auto-generated wrapper around sftp_aio_wait_read(). Original upstream documentation is below.
Wait for an asynchronous read to complete and store the read data in the supplied buffer.
A pointer to an sftp aio handle should be passed while calling this function. Except when the return value is SSH_AGAIN, this function releases the memory corresponding to the supplied aio handle and assigns NULL to that aio handle using the passed pointer to that handle.
If the file is opened in non-blocking mode and the request hasn't been executed yet, this function returns SSH_AGAIN and must be called again using the same sftp aio handle.
Arguments
aio: Pointer to the sftp aio handle returned bysftp_aio_begin_read().buf: Pointer to the buffer in which read data will be stored.buf_size: Size of the buffer in bytes. It should be bigger or equal to the length parameter of thesftp_aio_begin_read() call.
Returns
Number of bytes read, 0 on EOF, SSH_ERROR if an error occurred, SSH_AGAIN if the file is opened in nonblocking mode and the request hasn't been executed yet.
See also
LibSSH.lib.sftp_aio_wait_write — Method
sftp_aio_wait_write(aio::Ptr{sftp_aio})Auto-generated wrapper around sftp_aio_wait_write(). Original upstream documentation is below.
Wait for an asynchronous write to complete.
A pointer to an sftp aio handle should be passed while calling this function. Except when the return value is SSH_AGAIN, this function releases the memory corresponding to the supplied aio handle and assigns NULL to that aio handle using the passed pointer to that handle.
If the file is opened in non-blocking mode and the request hasn't been executed yet, this function returns SSH_AGAIN and must be called again using the same sftp aio handle.
Arguments
aio: Pointer to the sftp aio handle returned bysftp_aio_begin_write().
Returns
Number of bytes written on success, SSH_ERROR if an error occurred, SSH_AGAIN if the file is opened in nonblocking mode and the request hasn't been executed yet.
See also
LibSSH.lib.sftp_async_read — Method
sftp_async_read(file, data, len, id)Wait for an asynchronous read to complete and save the data.
Arguments
file: The opened sftp file handle to be read from.data: Pointer to buffer to receive read data.len: Size of the buffer in bytes. It should be bigger or equal to the length parameter of thesftp_async_read_begin() call.id: The identifier returned by thesftp_async_read_begin() function.
Returns
Number of bytes read, 0 on EOF, SSH_ERROR if an error occurred, SSH_AGAIN if the file is opened in nonblocking mode and the request hasn't been executed yet.
See also
LibSSH.lib.sftp_async_read_begin — Method
sftp_async_read_begin(file, len)Start an asynchronous read from a file using an opened sftp file handle.
Its goal is to avoid the slowdowns related to the request/response pattern of a synchronous read. To do so, you must call 2 functions:
sftp_async_read_begin() and sftp_async_read().
The first step is to call sftp_async_read_begin(). This function returns a request identifier. The second step is to call sftp_async_read() using the returned identifier.
When calling this function, the internal offset is updated corresponding to the len parameter.
A call to sftp_async_read_begin() sends a request to the server. When the server answers, libssh allocates memory to store it until sftp_async_read() is called. Not calling sftp_async_read() will lead to memory leaks.
Arguments
file: The opened sftp file handle to be read from.len: Size to read in bytes.
Returns
An identifier corresponding to the sent request, < 0 on error.
See also
sftp_async_read(), sftp_open()
LibSSH.lib.sftp_attributes_free — Method
sftp_attributes_free(file)Free a sftp attribute structure.
Arguments
file: The sftp attribute structure to free.
LibSSH.lib.sftp_canonicalize_path — Method
sftp_canonicalize_path(sftp, path)Canonicalize a sftp path.
Arguments
sftp: The sftp session handle.path: The path to be canonicalized.
Returns
A pointer to the newly allocated canonicalized path, NULL on error. The caller needs to free the memory using ssh_string_free_char().
LibSSH.lib.sftp_chmod — Method
sftp_chmod(sftp, file, mode)Change permissions of a file
Arguments
sftp: The sftp session handle.file: The file which owner and group should be changed.mode: Specifies the permissions to use. It is modified by the process's umask in the usual way: The permissions of the created file are (mode & ~umask)
Returns
0 on success, < 0 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_chown — Method
sftp_chown(sftp, file, owner, group)Change the file owner and group
Arguments
sftp: The sftp session handle.file: The file which owner and group should be changed.owner: The new owner which should be set.group: The new group which should be set.
Returns
0 on success, < 0 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_close — Method
sftp_close(file::sftp_file)Auto-generated wrapper around sftp_close(). Original upstream documentation is below.
Close an open file handle.
Arguments
file: The open sftp file handle to close.
Returns
Returns SSH_NO_ERROR or SSH_ERROR if an error occurred.
See also
LibSSH.lib.sftp_closedir — Method
sftp_closedir(dir::sftp_dir)Auto-generated wrapper around sftp_closedir(). Original upstream documentation is below.
Close a directory handle opened by sftp_opendir().
Arguments
dir: The sftp directory handle to close.
Returns
Returns SSH_NO_ERROR or SSH_ERROR if an error occurred.
LibSSH.lib.sftp_dir_eof — Method
sftp_dir_eof(dir)Tell if the directory has reached EOF (End Of File).
Arguments
dir: The sftp directory handle.
Returns
1 if the directory is EOF, 0 if not.
See also
LibSSH.lib.sftp_expand_path — Method
sftp_expand_path(sftp, path)Canonicalize path using expand-path.com extension
Arguments
sftp: The sftp session handle.path: The path to be canonicalized.
Returns
A pointer to the newly allocated canonicalized path, NULL on error. The caller needs to free the memory using ssh_string_free_char().
LibSSH.lib.sftp_extension_supported — Method
sftp_extension_supported(sftp, name, data)Check if the given extension is supported.
Example:
sftp_extension_supported(sftp, "statvfs@openssh.com", "2");Arguments
sftp: The sftp session to use.name: The name of the extension.data: The data of the extension.
Returns
1 if supported, 0 if not.
LibSSH.lib.sftp_extensions_get_count — Method
sftp_extensions_get_count(sftp)Get the count of extensions provided by the server.
Arguments
sftp: The sftp session to use.
Returns
The count of extensions provided by the server, 0 on error or not available.
LibSSH.lib.sftp_extensions_get_data — Method
sftp_extensions_get_data(sftp, indexn; throw = true)Auto-generated wrapper around sftp_extensions_get_data(). Original upstream documentation is below.
Get the data of the extension provided by the server.
This is normally the version number of the extension.
Arguments
sftp: The sftp session to use.indexn: The index number of the extension data you want.
Returns
The data of the extension.
LibSSH.lib.sftp_extensions_get_name — Method
sftp_extensions_get_name(sftp, indexn; throw = true)Auto-generated wrapper around sftp_extensions_get_name(). Original upstream documentation is below.
Get the name of the extension provided by the server.
Arguments
sftp: The sftp session to use.indexn: The index number of the extension name you want.
Returns
The name of the extension.
LibSSH.lib.sftp_file_set_blocking — Method
sftp_file_set_blocking(handle)Make the sftp communication for this file handle blocking.
Arguments
handle:[in] The file handle to set blocking.
LibSSH.lib.sftp_file_set_nonblocking — Method
sftp_file_set_nonblocking(handle)Make the sftp communication for this file handle non blocking.
Arguments
handle:[in] The file handle to set non blocking.
LibSSH.lib.sftp_free — Method
sftp_free(sftp)Close and deallocate a sftp session.
Arguments
sftp: The sftp session handle to free.
LibSSH.lib.sftp_fstat — Method
sftp_fstat(file)Get information about a file or directory from a file handle.
Arguments
file: The sftp file handle to get the stat information.
Returns
The sftp attributes structure of the file or directory, NULL on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_fstatvfs — Method
sftp_fstatvfs(file)Get information about a mounted file system.
Arguments
file: An opened file.
Returns
A statvfs structure or NULL on error.
See also
LibSSH.lib.sftp_fsync — Method
sftp_fsync(file)Synchronize a file's in-core state with storage device
This calls the "fsync@openssh.com" extension. You should check if the extensions is supported using:
int supported = sftp_extension_supported(sftp, "fsync@openssh.com", "1");Arguments
file: The opened sftp file handle to sync
Returns
0 on success, < 0 on error with ssh and sftp error set.
LibSSH.lib.sftp_get_error — Method
sftp_get_error(sftp)Get the last sftp error.
Use this function to get the latest error set by a posix like sftp function.
Arguments
sftp: The sftp session where the error is saved.
Returns
The saved error (see server responses), < 0 if an error in the function occurred.
See also
Server responses
LibSSH.lib.sftp_hardlink — Method
sftp_hardlink(sftp, oldpath, newpath)Create a hard link.
Arguments
sftp: The sftp session handle.oldpath: Specifies the pathname of the file for which the new hardlink is to be created.newpath: Specifies the pathname of the hardlink to be created.
Returns
0 on success, -1 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_home_directory — Method
sftp_home_directory(sftp::sftp_session, username::Ptr{Cchar})Auto-generated wrapper around sftp_home_directory(). Original upstream documentation is below.
Get the specified user's home directory
This calls the "home-directory" extension. You should check if the extension is supported using:
int supported = sftp_extension_supported(sftp, "home-directory", "1");Arguments
sftp: The sftp session handle.username: username of the user whose home directory is requested.
Returns
On success, a newly allocated string containing the absolute real-path of the home directory of the user. NULL on error. The caller needs to free the memory using ssh_string_free_char().
LibSSH.lib.sftp_init — Method
sftp_init(sftp::sftp_session)Auto-generated wrapper around sftp_init(). Original upstream documentation is below.
Initialize the sftp protocol with the server.
This function involves the SFTP protocol initialization (as described in the SFTP specification), including the version and extensions negotiation.
Arguments
sftp: The sftp session to initialize.
Returns
0 on success, < 0 on error with ssh error set.
See also
sftp_new()
LibSSH.lib.sftp_limits — Method
sftp_limits(sftp)Get information about the various limits the server might impose.
Arguments
sftp: The sftp session handle.
Returns
A limits structure or NULL on error.
See also
LibSSH.lib.sftp_limits_free — Method
sftp_limits_free(limits)Free the memory of an allocated limits.
Arguments
limits: The limits to free.
LibSSH.lib.sftp_lsetstat — Method
sftp_lsetstat(sftp, file, attr)This request is like setstat (excluding mode and size) but sets file attributes on symlinks themselves.
Note, that this function can only set time values using 32 bit values due to the restrictions in the SFTP protocol version 3 implemented by libssh. The support for 64 bit time values was introduced in SFTP version 5, which is not implemented by libssh nor any major SFTP servers.
Arguments
sftp: The sftp session handle.file: The symbolic link which attributes should be changed.attr: The file attributes structure with the attributes set which should be changed.
Returns
0 on success, < 0 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_lstat — Method
sftp_lstat(session, path)Get information about a file or directory.
Identical to sftp_stat, but if the file or directory is a symbolic link, then the link itself is stated, not the file that it refers to.
Arguments
session: The sftp session handle.path: The path to the file or directory to obtain the information.
Returns
The sftp attributes structure of the file or directory, NULL on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_mkdir — Method
sftp_mkdir(sftp::sftp_session, directory::Ptr{Cchar}, mode::mode_t)Auto-generated wrapper around sftp_mkdir(). Original upstream documentation is below.
Create a directory.
Arguments
sftp: The sftp session handle.directory: The directory to create.mode: Specifies the permissions to use. It is modified by the process's umask in the usual way: The permissions of the created file are (mode & ~umask)
Returns
0 on success, < 0 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_new — Method
sftp_new(session::ssh_session)Auto-generated wrapper around sftp_new(). Original upstream documentation is below.
Creates a new sftp session.
This function creates a new sftp session and allocates a new sftp channel with the server inside of the provided ssh session. This function call is usually followed by the sftp_init(), which initializes SFTP protocol itself.
Arguments
session: The ssh session to use.
Returns
A new sftp session or NULL on error.
See also
LibSSH.lib.sftp_new_channel — Method
sftp_new_channel(session, channel)Start a new sftp session with an existing channel.
Arguments
session: The ssh session to use.channel: An open session channel with subsystem already allocated
Returns
A new sftp session or NULL on error.
See also
LibSSH.lib.sftp_open — Method
sftp_open(session::sftp_session, file::Ptr{Cchar}, accesstype::Cint, mode::mode_t)Auto-generated wrapper around sftp_open(). Original upstream documentation is below.
Open a file on the server.
Arguments
session: The sftp session handle.file: The file to be opened.accesstype: Is one of O_RDONLY, O_WRONLY or O_RDWR which request opening the file read-only,write-only or read/write. Acesss may also be bitwise-or'd with one or more of the following: O_CREAT - If the file does not exist it will be created. O_EXCL - When used with O_CREAT, if the file already exists it is an error and the open will fail. O_TRUNC - If the file already exists it will be truncated.mode: Mode specifies the permissions to use if a new file is created. It is modified by the process's umask in the usual way: The permissions of the created file are (mode & ~umask)
Returns
A sftp file handle, NULL on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_opendir — Method
sftp_opendir(session::sftp_session, path::Ptr{Cchar})Auto-generated wrapper around sftp_opendir(). Original upstream documentation is below.
Open a directory used to obtain directory entries.
Arguments
session: The sftp session handle to open the directory.path: The path of the directory to open.
Returns
A sftp directory handle or NULL on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_read — Method
sftp_read(file, buf, count)Read from a file using an opened sftp file handle.
This function caps the length a user is allowed to read from an sftp file.
The value used for the cap is same as the value of the max_read_length field of the sftp_limits_t returned by sftp_limits().
Arguments
file: The opened sftp file handle to be read from.buf: Pointer to buffer to receive read data.count: Size of the buffer in bytes.
Returns
Number of bytes read, < 0 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_readdir — Method
sftp_readdir(session::sftp_session, dir::sftp_dir)Auto-generated wrapper around sftp_readdir(). Original upstream documentation is below.
Get a single file attributes structure of a directory.
Arguments
session: The sftp session handle to read the directory entry.dir: The opened sftp directory handle to read from.
Returns
A file attribute structure or NULL at the end of the directory.
See also
sftp_opendir(), sftp_attribute_free(), sftp_closedir()
LibSSH.lib.sftp_readlink — Method
sftp_readlink(sftp, path)Read the value of a symbolic link.
Arguments
sftp: The sftp session handle.path: Specifies the path name of the symlink to be read.
Returns
The target of the link, NULL on error. The caller needs to free the memory using ssh_string_free_char().
See also
LibSSH.lib.sftp_rename — Method
sftp_rename(sftp::sftp_session, original::Ptr{Cchar}, newname::Ptr{Cchar})Auto-generated wrapper around sftp_rename(). Original upstream documentation is below.
Rename or move a file or directory.
Arguments
sftp: The sftp session handle.original: The original url (source url) of file or directory to be moved.newname: The new url (destination url) of the file or directory after the move.
Returns
0 on success, < 0 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_rewind — Method
sftp_rewind(file)Rewinds the position of the file pointer to the beginning of the file.
Arguments
file: Open sftp file handle.
LibSSH.lib.sftp_rmdir — Method
sftp_rmdir(sftp::sftp_session, directory::Ptr{Cchar})Auto-generated wrapper around sftp_rmdir(). Original upstream documentation is below.
Remove a directory.
Arguments
sftp: The sftp session handle.directory: The directory to remove.
Returns
0 on success, < 0 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_seek — Method
sftp_seek(file, new_offset)Seek to a specific location in a file.
Arguments
file: Open sftp file handle to seek in.new_offset: Offset in bytes to seek.
Returns
0 on success, < 0 on error.
LibSSH.lib.sftp_seek64 — Method
sftp_seek64(file, new_offset)Seek to a specific location in a file. This is the 64bit version.
Arguments
file: Open sftp file handle to seek in.new_offset: Offset in bytes to seek.
Returns
0 on success, < 0 on error.
LibSSH.lib.sftp_server_free — Method
sftp_server_free(sftp)Close and deallocate a sftp server session.
Arguments
sftp: The sftp session handle to free.
LibSSH.lib.sftp_server_init — Method
sftp_server_init(sftp)Initialize the sftp server.
Arguments
sftp: The sftp session to init.
Returns
0 on success, < 0 on error.
LibSSH.lib.sftp_server_new — Method
sftp_server_new(session, chan)Create a new sftp server session.
Arguments
session: The ssh session to use.chan: The ssh channel to use.
Returns
A new sftp server session.
LibSSH.lib.sftp_server_version — Method
sftp_server_version(sftp)Get the version of the SFTP protocol supported by the server
Arguments
sftp: The sftp session handle.
Returns
The server version.
LibSSH.lib.sftp_setstat — Method
sftp_setstat(sftp, file, attr)Set file attributes on a file, directory or symbolic link.
Note, that this function can only set time values using 32 bit values due to the restrictions in the SFTP protocol version 3 implemented by libssh. The support for 64 bit time values was introduced in SFTP version 5, which is not implemented by libssh nor any major SFTP servers.
Arguments
sftp: The sftp session handle.file: The file which attributes should be changed.attr: The file attributes structure with the attributes set which should be changed.
Returns
0 on success, < 0 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_stat — Method
sftp_stat(session::sftp_session, path::Ptr{Cchar})Auto-generated wrapper around sftp_stat(). Original upstream documentation is below.
Get information about a file or directory.
Arguments
session: The sftp session handle.path: The path to the file or directory to obtain the information.
Returns
The sftp attributes structure of the file or directory, NULL on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_statvfs — Method
sftp_statvfs(sftp, path)Get information about a mounted file system.
Arguments
sftp: The sftp session handle.path: The pathname of any file within the mounted file system.
Returns
A statvfs structure or NULL on error.
See also
LibSSH.lib.sftp_statvfs_free — Method
sftp_statvfs_free(statvfs_o)Free the memory of an allocated statvfs.
Arguments
statvfs_o: The statvfs to free.
LibSSH.lib.sftp_symlink — Method
sftp_symlink(sftp, target, dest)Create a symbolic link.
Arguments
sftp: The sftp session handle.target: Specifies the target of the symlink.dest: Specifies the path name of the symlink to be created.
Returns
0 on success, < 0 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_tell — Method
sftp_tell(file)Report current byte position in file.
Arguments
file: Open sftp file handle.
Returns
The offset of the current byte relative to the beginning of the file associated with the file descriptor. < 0 on error.
LibSSH.lib.sftp_tell64 — Method
sftp_tell64(file)Report current byte position in file.
Arguments
file: Open sftp file handle.
Returns
The offset of the current byte relative to the beginning of the file associated with the file descriptor.
LibSSH.lib.sftp_unlink — Method
sftp_unlink(sftp::sftp_session, file::Ptr{Cchar})Auto-generated wrapper around sftp_unlink(). Original upstream documentation is below.
Unlink (delete) a file.
Arguments
sftp: The sftp session handle.file: The file to unlink/delete.
Returns
0 on success, < 0 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_utimes — Method
sftp_utimes(sftp, file, times)Change the last modification and access time of a file.
Arguments
sftp: The sftp session handle.file: The file which owner and group should be changed.times: A timeval structure which contains the desired access and modification time.
Returns
0 on success, < 0 on error with ssh and sftp error set.
See also
LibSSH.lib.sftp_write — Method
sftp_write(file, buf, count)Write to a file using an opened sftp file handle.
This function caps the length a user is allowed to write to an sftp file.
The value used for the cap is same as the value of the max_write_length field of the sftp_limits_t returned by sftp_limits().
Arguments
file: Open sftp file handle to write to.buf: Pointer to buffer to write data.count: Size of buffer in bytes.
Returns
Number of bytes written, < 0 on error with ssh and sftp error set.
See also
sftp_open(), sftp_read(), sftp_close()
Threading
LibSSH.lib.ssh_threads_get_default — Method
ssh_threads_get_default()Returns a pointer to the appropriate callbacks structure for the environment, to be used with ssh_threads_set_callbacks.
Returns
A pointer to a ssh_threads_callbacks_struct to be used with ssh_threads_set_callbacks.
See also
LibSSH.lib.ssh_threads_get_noop — Method
ssh_threads_get_noop()Get the noop threads callbacks structure
This can be used with ssh_threads_set_callbacks. These callbacks do nothing and are being used by default.
Returns
Always returns a valid pointer to the noop callbacks structure.
See also
LibSSH.lib.ssh_threads_get_pthread — Method
ssh_threads_get_pthread()Returns a pointer on the pthread threads callbacks, to be used with ssh_threads_set_callbacks.
See also
LibSSH.lib.ssh_threads_set_callbacks — Method
ssh_threads_set_callbacks(cb)Set the thread callbacks structure.
This is necessary if your program is using libssh in a multithreaded fashion. This function must be called first, outside of any threading context (in your main() function for instance), before you call ssh_init().
libgcrypt 1.6 and bigger backend does not support custom callback. Using anything else than pthreads here will fail.
Arguments
cb:[in] A pointer to assh_threads_callbacks_structstructure, which contains the different callbacks to be set.
Returns
Always returns SSH_OK.
See also
ssh_threads_callbacks_struct, SSH_THREADS_PTHREAD
Other
LibSSH.lib.ssh_message_auth_interactive_request — Method
ssh_message_auth_interactive_request(msg, name, instruction, num_prompts, prompts, echo)Initiate keyboard-interactive authentication from a server.
LibSSH.lib.ssh_message_auth_reply_success — Method
ssh_message_auth_reply_success(msg, partial; throw = true)Auto-generated wrapper around ssh_message_auth_reply_success().
LibSSH.lib.sftp_limits_struct — Type
sftp_limits_structSFTP limits structure.
LibSSH.lib.sftp_limits_t — Type
Pointer to a sftp_limits_struct
LibSSH.lib.sftp_statvfs_struct — Type
sftp_statvfs_structSFTP statvfs structure.
LibSSH.lib.ssh_auth_callback — Type
SSH authentication callback for password and publickey auth.
Arguments
prompt: Prompt to be displayed.buf: Buffer to save the password. You should null-terminate it.len: Length of the buffer.echo: Enable or disable the echo of what you type.verify: Should the password be verified?userdata: Userdata to be passed to the callback function. Useful for GUI applications.
Returns
0 on success, < 0 on error.
LibSSH.lib.ssh_auth_gssapi_mic_callback — Type
SSH authentication callback. Tries to authenticates user with the "gssapi-with-mic" method
Implementations should verify that parameter user matches in some way the principal. user and principal can be different. Only the latter is guaranteed to be safe.
Arguments
session: Current session handleruser: Username of the user (can be spoofed)principal: Authenticated principal of the user, including realm.userdata: Userdata to be passed to the callback function.
Returns
SSH_AUTH_DENIED Authentication failed.
LibSSH.lib.ssh_auth_none_callback — Type
SSH authentication callback. Tries to authenticates user with the "none" method which is anonymous or passwordless.
Arguments
session: Current session handleruser: User that wants to authenticateuserdata: Userdata to be passed to the callback function.
Returns
SSH_AUTH_DENIED Authentication failed.
LibSSH.lib.ssh_auth_password_callback — Type
SSH authentication callback.
Arguments
session: Current session handleruser: User that wants to authenticatepassword: Password used for authenticationuserdata: Userdata to be passed to the callback function.
Returns
SSH_AUTH_DENIED Authentication failed.
LibSSH.lib.ssh_auth_pubkey_callback — Type
SSH authentication callback.
Arguments
session: Current session handleruser: User that wants to authenticatepubkey: public key used for authenticationsignature_state: SSH_PUBLICKEY_STATE_NONE if the key is not signed (simple public key probe), SSH_PUBLICKEY_STATE_VALID if the signature is valid. Others values should be replied with a SSH_AUTH_DENIED.userdata: Userdata to be passed to the callback function.
Returns
SSH_AUTH_DENIED Authentication failed.
LibSSH.lib.ssh_bind_callbacks — Type
Callbacks for a ssh_bind (upstream documentation).
LibSSH.lib.ssh_bind_callbacks_struct — Type
ssh_bind_callbacks_structThese are the callbacks exported by the ssh_bind structure.
They are called by the server module when events appear on the network.
LibSSH.lib.ssh_bind_incoming_connection_callback — Type
Incoming connection callback. This callback is called when a ssh_bind has a new incoming connection.
Arguments
sshbind: Current sshbind session handleruserdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_callback_data — Type
@brief callback for data received messages.
@param data data retrieved from the socket or stream
@param len number of bytes available from this stream
@param user user-supplied pointer sent along with all callback messages
@returns number of bytes processed by the callee. The remaining bytes will
be sent in the next callback message, when more data is available.
LibSSH.lib.ssh_callback_int — Type
@brief callback to process simple codes
@param code value to transmit
@param user Userdata to pass in callback
LibSSH.lib.ssh_callbacks_struct — Type
ssh_callbacks_structThe structure to replace libssh functions with appropriate callbacks.
LibSSH.lib.ssh_channel_auth_agent_req_callback — Type
SSH auth-agent-request from the client. This request is sent by a client when agent forwarding is available. Server is free to ignore this callback, no answer is expected.
Arguments
session: the sessionchannel: the channeluserdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_channel_close_callback — Type
SSH channel close callback. Called when a channel is closed by remote peer
Arguments
session: Current session handlerchannel: the actual channeluserdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_channel_data_callback — Type
SSH channel data callback. Called when data is available on a channel
Arguments
session: Current session handlerchannel: the actual channeldata: the data that has been read on the channellen: the length of the datais_stderr: is 0 for stdout or 1 for stderruserdata: Userdata to be passed to the callback function.
Returns
number of bytes processed by the callee. The remaining bytes will be sent in the next callback message, when more data is available.
LibSSH.lib.ssh_channel_env_request_callback — Type
SSH channel environment request from a client.
some environment variables can be dangerous if changed (e.g. LD_PRELOAD) and should not be fulfilled.
Arguments
session: the sessionchannel: the channelenv_name: name of the environment value to be setenv_value: value of the environment value to be setuserdata: Userdata to be passed to the callback function.
Returns
1 if the request is denied
LibSSH.lib.ssh_channel_eof_callback — Type
SSH channel eof callback. Called when a channel receives EOF
Arguments
session: Current session handlerchannel: the actual channeluserdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_channel_exec_request_callback — Type
SSH channel Exec request from a client.
Arguments
session: the sessionchannel: the channelcommand: the shell command to be executeduserdata: Userdata to be passed to the callback function.
Returns
1 if the request is denied
LibSSH.lib.ssh_channel_exit_signal_callback — Type
SSH channel exit signal callback. Called when a channel has received an exit signal
Arguments
session: Current session handlerchannel: the actual channelsignal: the signal name (without the SIG prefix)core: a boolean telling whether a core has been dumped or noterrmsg: the description of the exceptionlang: the language of the description (format: RFC 3066)userdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_channel_exit_status_callback — Type
SSH channel exit status callback. Called when a channel has received an exit status
Arguments
session: Current session handlerchannel: the actual channelexit_status: Exit status of the ran commanduserdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_channel_open_request_auth_agent_callback — Type
Handles an SSH new channel open "auth-agent" request. This happens when the server sends back an "auth-agent" connection attempt. This is a client-side API
Arguments
session: current session handleruserdata: Userdata to be passed to the callback function.
Returns
NULL if the request should not be allowed
LibSSH.lib.ssh_channel_open_request_forwarded_tcpip_callback — Type
Handles an SSH new channel open "forwarded-tcpip" request. This happens when the server forwards an incoming TCP connection on a port it was previously requested to listen on. This is a client-side API
Arguments
session: current session handlerdestination_address: the address that the TCP connection connected todestination_port: the port that the TCP connection connected tooriginator_address: the originator IP addressoriginator_port: the originator portuserdata: Userdata to be passed to the callback function.
Returns
NULL if the request should not be allowed
LibSSH.lib.ssh_channel_open_request_session_callback — Type
Handles an SSH new channel open session request
Arguments
session: current session handleruserdata: Userdata to be passed to the callback function.
Returns
NULL if the request should not be allowed
LibSSH.lib.ssh_channel_open_request_x11_callback — Type
Handles an SSH new channel open X11 request. This happens when the server sends back an X11 connection attempt. This is a client-side API
Arguments
session: current session handleruserdata: Userdata to be passed to the callback function.originator_address: IP address of the machine who sent the requestoriginator_port: port number of the machine who sent the request
Returns
NULL if the request should not be allowed
LibSSH.lib.ssh_channel_open_resp_callback — Type
SSH channel open callback. Called when a channel open succeeds or fails.
Arguments
session: Current session handlerchannel: the actual channelis_success: is 1 when the open succeeds, and 0 otherwise.userdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_channel_pty_request_callback — Type
SSH channel PTY request from a client.
Arguments
session: the sessionchannel: the channelterm: The type of terminal emulationwidth: width of the terminal, in charactersheight: height of the terminal, in characterspxwidth: width of the terminal, in pixelspwheight: height of the terminal, in pixelsuserdata: Userdata to be passed to the callback function.
Returns
-1 if the request is denied
LibSSH.lib.ssh_channel_pty_window_change_callback — Type
SSH channel PTY windows change (terminal size) from a client.
Arguments
session: the sessionchannel: the channelwidth: width of the terminal, in charactersheight: height of the terminal, in characterspxwidth: width of the terminal, in pixelspwheight: height of the terminal, in pixelsuserdata: Userdata to be passed to the callback function.
Returns
-1 if the request is denied
LibSSH.lib.ssh_channel_request_resp_callback — Type
SSH channel request response callback. Called when a response to the pending request is received.
Arguments
session: Current session handlerchannel: the actual channeluserdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_channel_shell_request_callback — Type
SSH channel Shell request from a client.
Arguments
session: the sessionchannel: the channeluserdata: Userdata to be passed to the callback function.
Returns
1 if the request is denied
LibSSH.lib.ssh_channel_signal_callback — Type
SSH channel signal callback. Called when a channel has received a signal
Arguments
session: Current session handlerchannel: the actual channelsignal: the signal name (without the SIG prefix)userdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_channel_subsystem_request_callback — Type
SSH channel subsystem request from a client.
Arguments
session: the sessionchannel: the channelsubsystem: the subsystem requireduserdata: Userdata to be passed to the callback function.
Returns
1 if the request is denied
LibSSH.lib.ssh_channel_write_wontblock_callback — Type
SSH channel write will not block (flow control).
Arguments
session: the sessionchannel: the channelbytes:[in] size of the remote window in bytes. Writing as much data will not block.userdata:[in] Userdata to be passed to the callback function.
Returns
0 default return value (other return codes may be added in future).
LibSSH.lib.ssh_channel_x11_req_callback — Type
SSH X11 request from the client. This request is sent by a client when X11 forwarding is requested(and available). Server is free to ignore this callback, no answer is expected.
Arguments
session: the sessionchannel: the channelsingle_connection: If true, only one channel should be forwardedauth_protocol: The X11 authentication method to be usedauth_cookie: Authentication cookie encoded hexadecimalscreen_number: Screen numberuserdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_control_master_options_e — Type
ssh_control_master_options_e@}
LibSSH.lib.ssh_file_format_e — Type
ssh_file_format_e@}
LibSSH.lib.ssh_global_request_callback — Type
SSH global request callback. All global request will go through this callback.
Arguments
session: Current session handlermessage: the actual messageuserdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_jump_authenticate_callback — Type
SSH proxyjump user authentication callback. Authenticate the user.
Arguments
session: Jump session handleruserdata: Userdata to be passed to the callback function.
Returns
0 on success, < 0 on error.
LibSSH.lib.ssh_jump_before_connection_callback — Type
SSH proxyjump before connection callback. Called before calling ssh_connect()
Arguments
session: Jump session handleruserdata: Userdata to be passed to the callback function.
Returns
0 on success, < 0 on error.
LibSSH.lib.ssh_jump_verify_knownhost_callback — Type
SSH proxyjump verify knownhost callback. Verify the host. If not specified default function will be used.
Arguments
session: Jump session handleruserdata: Userdata to be passed to the callback function.
Returns
0 on success, < 0 on error.
LibSSH.lib.ssh_log_callback — Type
SSH log callback. All logging messages will go through this callback
Arguments
session: Current session handlerpriority: Priority of the log, the smaller being the more importantmessage: the actual messageuserdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_logging_callback — Type
SSH log callback.
All logging messages will go through this callback.
Arguments
priority: Priority of the log, the smaller being the more important.function: The function name calling the logging functions.buffer: The actual messageuserdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_packet_callback — Type
Prototype for a packet callback, to be called when a new packet arrives
Arguments
session: The current session of the packettype: packet type (see ssh2.h)packet: buffer containing the packet, excluding size, type and padding fieldsuser: user argument to the callback and are called each time a packet shows up
Returns
SSH_PACKET_NOT_USED Packet was not used or understood, processing must continue
LibSSH.lib.ssh_server_callbacks_struct — Type
ssh_server_callbacks_structThis structure can be used to implement a libssh server, with appropriate callbacks.
LibSSH.lib.ssh_service_request_callback — Type
Handles an SSH service request
Arguments
session: current session handlerservice: name of the service (e.g. "ssh-userauth") requesteduserdata: Userdata to be passed to the callback function.
Returns
-1 if the request should not be allowed
LibSSH.lib.ssh_session — Type
Session struct (upstream documentation).
LibSSH.lib.ssh_socket_callbacks_struct — Type
ssh_socket_callbacks_structThese are the callbacks exported by the socket structure They are called by the socket module when a socket event appears
LibSSH.lib.ssh_status_callback — Type
SSH Connection status callback.
Arguments
session: Current session handlerstatus: Percentage of connection status, going from 0.0 to 1.0 once connection is done.userdata: Userdata to be passed to the callback function.
LibSSH.lib.ssh_thread_callback — Type
libssh_threads
@{
LibSSH.lib.ssh_threads_callbacks_struct — Type
ssh_threads_callbacks_structThreads callbacks. See ssh_threads_set_callbacks