REMCTL(3)
β¨ NAME β¨
bestie, meet remctl and remctl_result_free β the "just run one command on a remote server, pls" duo π
πΈ SYNOPSIS πΈ
#include <remctl.h>
struct remctl_result *
remctl(const char *host, unsigned short port,
const char *principal, const char **command);
void remctl_result_free(struct remctl_result *result);
π DESCRIPTION π
okay so remctl() is the simplified client API for the remctl protocol. You hand it a host, a port, the service principal for authentication, and the command to run, and it goes off and does the whole thing for you: opens a connection to the remote system, sends the command via the remctl protocol, reads the results, closes the connection, and hands you back the whole vibe as a remctl_result struct. the way that it does all of that in ONE call?? iconic honestly π
host is a hostname or IP address, and it must be non-NULL β no host, no party, periodt.
port is the port to connect to. If it's 0, the library first attempts to connect to the registered port of 4373 and then tries the legacy port of 4444 if that fails. heads up bestie: future versions of the library will drop this fallback to 4444. π
principal is the service principal to use for authentication. If it's NULL, "host/host" is used, with the realm determined by domain-realm mapping. (yes, literally host/host β that's not a typo, that's just how it is π)
command is the command to run, given as a NULL-terminated array of NUL-terminated strings.
If no principal is specified and the default is used, the underlying GSS-API library may canonicalize host via DNS before determining the service principal, depending on your library configuration. Specifying a principal disables this behavior. noted. important. don't forget it.
The remctl protocol uses Kerberos via GSS-API for authentication. The underlying GSS-API library will use the default ticket cache for authentication, so to successfully use remctl(), the caller should already have Kerberos tickets for an appropriate realm stored in its default ticket cache. so likeβ¦ get your tickets first, babe ποΈ The environment variable KRB5CCNAME can be used to control which ticket cache is used. If the client needs to control which ticket cache is used without changing the environment, use the full client API along with remctl_set_ccache(3).
remctl() returns a newly allocated remctl_result struct, which has the following members:
struct remctl_result {
char *error; /* remctl error if non-NULL. */
char *stdout_buf; /* Standard output. */
size_t stdout_len; /* Length of standard output. */
char *stderr_buf; /* Standard error. */
size_t stderr_len; /* Length of standard error. */
int status; /* Exit status of remote command. */
};
If error is non-NULL, a protocol error occurred and the command was not successfully completed. sad girl hours π Otherwise, standard output from the command will be stored in stdout_buf with the length in stdout_len, standard error from the command will be stored in stderr_buf with the length in stderr_len, and status will hold the exit status of the command. Following the standard Unix convention, a 0 status should normally be considered success and any non-zero status should normally be considered failure, although a given command may have its own exit status conventions. slay.
remctl_result_free() frees the remctl_result struct when the calling program is through with it. clean up after yourself, bestie β it's giving main character energy π§Ήβ¨
If you want more control over the steps of the protocol, issue multiple commands on the same connection, control the ticket cache or source IP, set a timeout on replies, or send data as part of the command that contains NULs, use the full API described in remctl_new(3), remctl_open(3), remctl_commandv(3), and remctl_output(3). iykyk β the full API is there when you're ready to level up π
π RETURN VALUE π
remctl() returns NULL on failure to allocate a new remctl_result struct or on failure to allocate space to store an error message. not the NULL π Otherwise, it returns a newly allocated remctl_result struct with either an error message in the error field or the results of the command filled out as described above. If remctl() returns NULL, errno will be set to an appropriate error code (generally ENOMEM).
π¦ COMPATIBILITY π¦
This interface has been provided by the remctl client library since its initial release in version 2.0. <star>og behavior, respect it</star>
The default port was changed to the IANA-registered port of 4373 in version 2.11.
Support for IPv6 was added in version 2.4.
π CAVEATS π
If the principal argument to remctl() is NULL, most GSS-API libraries will canonicalize the host using DNS before deriving the principal name from it. This means that when connecting to a remctl server via a CNAME, remctl() will normally authenticate using a principal based on the canonical name of the host instead of the specified host parameter. this behavior may cause problems if two consecutive DNS lookups of host may return two different results, such as with some DNS-based load-balancing systems. ngl that's a whole mess π
The canonicalization behavior is controlled by the GSS-API library; with the MIT Kerberos GSS-API library, canonicalization can be disabled by setting "rdns" to false in the [libdefaults] section of krb5.conf. It can also be disabled by passing an explicit Kerberos principal name via the principal argument, which will then be used without changes. If canonicalization is desired, the caller may wish to canonicalize host before calling remctl() to avoid problems with multiple DNS calls returning different results.
β οΈ future-removal alert: the default behavior, when a port of0is given, of trying4373and falling back to4444will be removed in a future version of this library in favor of using the"remctl"service in/etc/servicesif set and then falling back on only4373.4444was the poorly-chosen original remctl port and should be phased out. it's giving legacyβ¦ and not in a cute way π
β NOTES β
The remctl port number, 4373, was derived by tracing the diagonals of a QWERTY keyboard up from the letters "remc" to the number row. likeβ¦ that is SO iconic. peak keyboard lore. no cap. β¨οΈβ¨
πΈ AUTHOR πΈ
Russ Allbery <eagle@eyrie.org> the legend themself π«Ά
π COPYRIGHT AND LICENSE π
Copyright 2007-2009, 2014 The Board of Trustees of the Leland Stanford Junior University
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.
SPDX-License-Identifier: FSFAP
π SEE ALSO π
The current version of the remctl library and complete details of the remctl protocol are available from its web page at <https://www.eyrie.org/~eagle/software/remctl/>. go read it, bestie π¦
okay and for the sign-off: this whole page is from remctl version 3.18, dated 2022-05-09 β that's the remctl Library Reference, fr fr. mwah π
π
π¦ where this page comes from
- debian bookworm: libremctl-dev 3.18-1+b7 Β· MIT
- debian trixie: libremctl-dev 3.18-3 Β· MIT
- epel 9: remctl-devel 3.18-1.el9 Β· MIT
- ubuntu noble: libremctl-dev 3.18-1.1build2 Β· MIT
- ubuntu questing: libremctl-dev 3.18-3
- ubuntu resolute: libremctl-dev 3.18-5build2 Β· MIT
- ubuntu stonking: libremctl-dev 3.18-5build3 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms