REMCTLD(8)
β¨ NAME β¨
remctld β the server for remctl, a remote command execution utility. π
π SYNOPSIS π
remctld [-dFhmSvZ] [-b bind-address [-b bind-address ...]]
[-f config] [-k keytab] [-P file] [-p port]
[-s service]
πΈ DESCRIPTION πΈ
okay so bestie, remctld is literally the server half of remctl. It accepts a connection from remctl, receives the command to execute and the arguments, verifies authorization of the user and executes the command, returning the result back to the client. π
And the security?? Not me being obsessed β all connections are authenticated using Kerberos GSS-API Kerberos, and all transmissions are also encrypted using the GSS-API privacy layer. no cap. π₯
remctld is normally started using tcpserver or from inetd, but it may be run in stand-alone mode as a daemon using -m. Either -s must be given to use an alternate identity (which will require the same flag be used for remctl client invocations), or it must be run as root to read the host keytab file. remctld logs its activity using syslog (the daemon facility).
The location of the configuration file may be specified with the -f option. The default location is /etc/remctl/remctl.conf. For information on the format of the configuration file, see "CONFIGURATION FILE" below. π
When the command is run, several environment variables will be set providing information about the remote connection. See ENVIRONMENT below for more information. π
Command-line and configuration options and ACL methods are annotated below with the version at which they were added. For version information for more general features, see COMPATIBILITY below. β
π OPTIONS π
The start of each option description is annotated with the version of remctld in which that option was added with its current meaning. iykyk π
-bbind-address β [2.17] When running as a standalone server, bind to the specified local address rather than listening on all interfaces. This option may be given multiple times to bind to multiple addresses. bind-address must be an IP address (either IPv4 or IPv6), not a hostname. Only makes sense in combination with-m.
This option is ignored if remctld is passed already open sockets via the systemd socket activation protocol. In that case, the bind addresses of the sockets should be controlled via the systemd configuration.
-dβ [1.10] Enable verbose debug logging tosyslog(or to standard output if-Sis also given). π-Fβ [2.8] Normally when running in stand-alone mode (-m),remctldbackgrounds itself to run as a daemon, changes directory to/, and drops any controlling terminal. This flag suppresses this behavior, usually for debugging or so thatremctldcan be monitored by other processes.-fconfig β [1.0] The configuration file forremctld, overriding the default path. π-hβ [1.10] Show a brief usage message and then exit. This usage method will include a list of supported ACL types and can be used to determine if optional ACL methods were compiled into a givenremctldbuild. π«Ά-kkeytab β [2.8] Use keytab as the keytab for server credentials rather than the system default or the value of theKRB5_KTNAMEenvironment variable. Using-kjust sets theKRB5_KTNAMEenvironment variable internally in the process.-mβ [2.8] Enable stand-alone mode.remctldwill listen to its configured port and fork a new child for each incoming connection. By default, when this option is used,remctldalso changes directory to/, backgrounds itself, and closes standard input, output, and error. To not background, pass-Fas well. To not close standard output and error and continue using them for logging, pass-Sas well.
To determine the port, remctld attempts to look up the "remctl" service in the local /etc/services file and uses the port defined there. If the "remctl" service could not be found, it uses 4373, the registered remctl port. π’
When running in stand-alone mode, send the SIGHUP signal to remctld to ask it to re-read its configuration file and SIGTERM to ask it to exit.
-Pfile β [2.0] When running in stand-alone mode (-m), write the PID ofremctldto file. This option is ignored unless-mis also given.-pport β [1.0] When running in stand-alone mode, listen on port port rather than the default. This option does nothing unless used with-m.
This option is ignored if remctld is passed already open sockets via the systemd socket activation protocol. In that case, the listening port should be controlled via the systemd configuration.
-Sβ [2.3] Rather than logging tosyslog, log debug and routine connection messages to standard output and error messages to standard error. This option is mostly useful for testing and debugging. π§ͺ-sservice β [1.0] Specifies which principal is used as the server identity for client authentication. The client must also use the same identity as the server identity for authentication to succeed. By default,remctldaccepts any principal with a key in the default keytab file (which can be changed with the-koption). This is normally the most desirable behavior. β¨-vβ [1.10] Print the version ofremctldand exit.-Zβ [3.7] Whenremctldis running in stand-alone mode, after it has set up its network socket and is ready to answer requests, raiseSIGSTOP. This signals to upstart, when using"expect stop", that the daemon is ready to accept connections, and upstart will raiseSIGCONTto allowremctldto continue. This option is probably only useful when using upstart as the init system. Only makes sense in combination with-m.
π CONFIGURATION FILE π
The configuration file defines the allowed commands and specifies access control information. The configuration file format is lines of space- or tab-separated strings, where each line is:
command subcommand executable [option=value ...] acl [acl ...]
Each command consists of a command, a subcommand, and zero or more arguments. Each configuration line defines an acceptable command and subcommand (or, if "ALL" is used as mentioned below under command and subcommand, a set of commands). The first configuration line matching the received command is used, so list more specific entries before more general entries. π
Blank lines and lines beginning with "#" are ignored. Lines can be continued on the next line by ending them with a backslash ("\"). Be aware that comments can be continued with a backslash as well. π (yes fr, that's a real thing to watch out for)
As a special case, a line like:
include file
will include file as if its contents were pasted verbatim into the configuration file at that point. file may be a directory, in which case all files whose names do not contain a period found in that directory will be included (in no particular order). file should be a fully qualified path.
The configuration file is loaded when remctld starts and is normally not re-read. To trigger a re-read of the configuration file when remctld is running in stand-alone mode, send the SIGHUP signal to the remctld process. π
The meaning of the fields on each configuration line are:
- command β The command being issued or the special keyword
"ALL". Normally, related commands (such as all commands for managing a particular service) are grouped together as subcommands under one command.
If the keyword "ALL" is used instead of a specific subcommand, this line matches all commands with the given subcommand (so "ALL ALL" matches any command) and can be used to dispatch all commands to the same executable with the same ACLs. Since the first matching entry is used, list entries for specific commands first (if any) and then the "ALL" catch-all.
Note that while the subcommand is passed to the executable as a command-line option, the command is not. The command is available to the executable in the environment variable REMCTL_COMMAND (see ENVIRONMENT below).
The command "help" is handled specially if no such command is defined in the configuration file. See below under the "help" and "summary" options.
- subcommand β The subcommand within the command being requested, such as
"release"for the release function of the AFS volume backend, or one of the special keywords"ALL"or"EMPTY".
If the keyword "ALL" is used instead of a specific subcommand, this line matches all subcommands with the given command and can be used to dispatch all subcommands under that command to the same executable with the same ACLs. Since the first matching entry is used, list entries for specific services first (if any) and then the "ALL" catch-all.
If the keyword "EMPTY" is used instead of a specific subcommand, this line matches only commands where no subcommand was given.
The subcommand is always passed as the first argument to the executable program that is listed for that service unless no subcommand was given.
- executable β The full path to the command executable to run for this command and subcommand combination. (See examples below.) π
- option=value β An option setting that applies to this command. Supported option settings, annotated with the version at which that option was added in its current form, are:
help=arg β [3.2] Specifies the argument for this command that will print help for a particular subcommand to standard output.
If remctld receives the command "help" with one or two arguments, and no "help" command is defined in the configuration file, the server will take the command arguments as a command and subcommand. It will then look through the configuration for a configuration line matching that command and subcommand with a "help" option set. If one is found and the user is authorized to run that command, the server will run the specified executable with the argument arg and second and optional third arguments taken from the arguments to the "help" command, sending the output back to the user. π
This permits a standard interface to get additional help for a particular remctl command. Also see the "summary" option.
logmask=n[,...]β [1.4] okay so this is your privacy filter for logs, bestie. Any argument you list in thelogmasklist gets its value logged as"**MASKED**"instead of the real thing. Why? Because some commands take secrets like passwords and you do not want those sitting in your logs. Thelogmasklist is just argument numbers separated by commas, and the subcommand counts as argument 1. The command argument itself? Can't be masked, sorry. Example time: if the command isadmin passwd username password, you'd setlogmaskto3so the password argument shows up as"**MASKED**". And if the command isuser passwd username old-password new-password, you'd setlogmaskto"3,4". Slay. πstdin=(n | "last")β [2.14] this one is for when you wanna pass an argument on standard input instead of on the command line. The value has to be either the number of the argument (again, subcommand is argument 1) or the special string"last", which means the final argument, no matter how many there are, gets passed on stdin. But heads up: the command itself cannot go on standard input, sonmust be at least1. And if you set it to"last"but there are no arguments besides the command and maybe the subcommand, then nothing gets passed on standard input. This is mainly for big data that won't fit on the command line, or data withNULcharacters. It's also great for passwords you don't want exposed on the command line. Only at most one argument can be passed on standard input. Also, even if the subcommand is the designated argument to pass on standard input (likestdin=1), the subcommand still may not containNULcharacters. So don't try it. π«Άsudo=(username | #uid)β [3.12] run this command as the specified user usingsudo. This is exactly the same as prependingsudo -u username --to the command before running it. The path tosudois decided whenremctldis built. Theuseroption is simpler and easier ifremctldis running as root. But sometimes you might wanna runremctldas a non-root user, andremctl-shell(which shares the same config files) usually runs as a non-root user anyway. In those cases, this option lets you usesudoto switch users before running the command. And since the argument is passed verbatim tosudo's-uoption, you can specify a numeric UID by prepending it with#. Cute. πsummary=argβ [3.13] this specifies the argument for this command that will print a usage summary to standard output. Here's the vibe: ifremctldgets the command"help"with no arguments, and no"help"command is defined in the config file, the server will look through the config for any command with a"summary"option set. If it finds one, and the user is authorized to run that command, the server will run the specified executable with the argumentarg, sending the output back to the user. It does this for every command in the config that meets those criteria. This lets you show a summary of available commands based on what the user is actually authorized to run. It's like a lightweight form of service discovery. Also see the"help"option. Iconic. β¨user=(username | uid)β [3.1] run this command as the specified user, which can be a username or a UID. Even if you give a UID, the user must be found in the user database (searched viagetpwuid(3)).remctldwill run the command as that user, including that user's primary and supplemental groups. No cap. π―
aclβ one or more entries of the form[method:]data, wheremethodspecifies an access control method anddatacontains parameters whose meaning depends on the method. Ifmethodis omitted, thedatais processed as described for the"file"method. But watch out: ifmethodis omitted,aclmust either begin with/or must not contain=. Otherwise, it gets parsed as an option instead. If there's any ambiguity, just prepend the method. Also, special exception for backward compatibility: the ACL"ANYUSER"(case-sensitive) is treated as equivalent to"anyuser:auth". Each entry is checked in order, and access is granted as soon as an entry matches. If no entry matches, access is denied. The following methods may be supported; however, be aware that the availability of several ACL types depends on whetherremctldwas built with that support. Each ACL type is annotated with the version in which it was added. Now let's get into the methods: πanyuserβ [3.10] permit access to any user. This comes in two forms:anyuser:authβ permit any authenticated user. This means not only the local Kerberos realm but also any realm with which there is a cross-realm trust relationship.anyuser:anonymousβ permit entirely anonymous users. This means no authentication whatsoever is required to run the command. Any client with network access to the server can run the command (using anonymous PKINIT), assuming that anonymous service tickets are enabled for the local Kerberos realm.
For backwards compatibility, the ACL "ANYUSER" is treated as identical to "anyuser:auth". This was the only supported any-user ACL syntax prior to remctl 3.10. π
fileβ [2.13] thedatais the full path of an ACL file or to a directory containing ACL files. Directories are handled as described for theincludedirective in configuration files. An ACL file contains one entry per line, in the[method:]dataform described above. Entries are handled exactly as if they had appeared in the configuration file except that the default method is"princ"instead of"file". Blank lines and lines beginning with#are ignored in the ACL files. For backward compatibility, a line likeinclude [<method>:]<data>in an ACL file behaves exactly as if the"include"directive had been omitted, except that the default method is"file". Thus, writinginclude <path>in an ACL file is the same as writingfile:<path>and is handled identically to theincludedirective in configuration files. πprincβ [2.13] thedatais the name of a Kerberos v5 principal which is to be granted access, such as"username@EXAMPLE.ORG". ποΈdenyβ [2.13] this method is used to selectively deny access. Thedatais parsed as a[method:]dataand evaluated as described above, with the default scheme being"princ". If it matches, access is denied immediately without examining any further entries. Otherwise, processing continues. Remember that access is granted as soon as an entry matches. For"deny"rules to be effective, they therefore must come before any ACLs they are intended to override. Be careful when using"deny"when including a directory of ACL files, since the files in that directory are read in an undefined order (not in alphabetical order by filename). It's best to explicitly include the file containing"deny"ACL rules first. Note that"deny"only denies access; it never grants it. Thus, deny alone does not grant access to anyone, and using deny on itself as in"deny:deny:foo"neither denies nor grants access to anyone. πgputβ [2.13] this method is used to grant access based on the CMU GPUT (Global Privileged User Table -- seegput(5)). Thedatais either a GPUT role name or a string of the formgroup[xform], wheregroupis a GPUT role name andxformis a GPUT transform string. Access is granted if the user is a member of the specified GPUT group, after applying either the optionalxformor the default transform. This method is supported only ifremctldwas compiled with GPUT support by using the"--with-gput"configure option. πlocalgroupβ [3.9] this method is used to grant or deny access based on membership in local UNIX groups. Thedatais taken to be a name of a local system group. The user principal is converted to a local user name withkrb5_aname_to_localname(3)and then compared to the members of the given group. For example, to allow access to the members of group"goodguys", use an ACL of"localgroup:goodguys"syntax. To deny access to the members of group"badguys", use"deny:localgroup:badguys".krb5_aname_to_localname()follows local configuration rules to determine how to convert Kerberos principal to local users. If the realm of the principal is not in a local realm and is not otherwise covered by one of those rules, the principal will be unchanged, which will almost certainly mean that it will not be a member of any local group and access will be denied. This method is supported only ifremctldwas built with Kerberos support and thegetgrnam_r(3)library function was supported by the C library when it was built. π₯pcreβ [2.16] this method is used to grant or deny access based on Perl-compatible regular expressions. Thedatais taken to be a Perl-compatible regular expression and matched against the user identity. To deny access, use the"deny:pcre:regex"syntax. The regular expression is not automatically anchored, so be careful to anchor it at the start and end (with"\A"and"\z") to ensure that the entire principal name is matched, unless you intend to allow partial matches. This method is supported only ifremctldwas compiled with PCRE support (either PCRE2 or PCRE1). π§
regex π«
regex[2.16] β this ACL method grants or denies access using POSIX extended regular expressions. The data gets treated as a POSIX extended regular expression (yk, the same flavoregrepuses) and matched against the user identity. Wanna deny instead? Use thedeny:regex:regexsyntax. π
The regex is not automatically anchored, bestie, so be careful β anchor it at the start and end with ^ and $ so the entire principal name gets matched, unless you genuinely mean to allow partial matches. π
This method is only supported if a library for POSIX-compatible regular expressions was found when remctld was built. No library, no regex ACLs, periodt.
To see the list of ACL types supported by a particular build of remctld, run remctld -h. β¨
The keyword ANYUSER may be used instead of the ACLs to allow access to all users. The user still needs to authenticate to remctld β this only affects authorization. Use it for backend programs that want to check ACLs themselves and will grab the authenticated principal from the REMOTE_USER environment variable. Note that ANYUSER accepts any authenticated user, including cross-realm users from foreign Kerberos realms. π«Ά
πΏ ENVIRONMENT πΏ
remctld itself uses the following environment variables when run in stand-alone mode (-m):
LISTEN_FDS,LISTEN_PIDβ if these environment variables are set,remctldwill expect to be provided its listening sockets via the systemd socket activation protocol and will not attempt to bind its own sockets. For more deets on the protocol, seedaemon(7)andsd_listen_fds(3). π§NOTIFY_SOCKETβ if this environment variable is set,remctldwill notify the socket named in this variable when it's ready to accept incoming packets, using the systemd status notification protocol. More details live indaemon(7)andsd_notify(3). π
Note that using socket activation is recommended when running under systemd in stand-alone mode, and status notification is not necessary or useful when using socket activation.
When running in stand-alone mode, these environment variables will be cleared by remctld before running any commands. π§Ή
The following environment variables will be set for any commands run via remctld (annotated with the version at which they were added):
REMCTL_COMMAND[2.16] β the command string that caused this command to be run. This variable will contain only the command, not the subcommand or any additional arguments (those get passed as command arguments).REMOTE_ADDR[2.1] β the IP address of the remote host. This may be IPv4 or IPv6. πREMOTE_EXPIRES[3.10] β the time (in seconds since UNIX epoch) when the authenticated remote session will expire. This will normally be the expiration time of the Kerberos ticket used to authenticate to the server. β³REMOTE_HOST[2.1] β the hostname of the remote host, if it was available. If reverse name resolution failed, this environment variable will not be set.
This is determined via a simple reverse DNS lookup and should be considered under the control of the client. remctl commands should treat it with skepticism and not use it for anything other than logging purposes. π
REMOTE_USER,REMUSER[1.0 forREMUSER, 2.1 forREMOTE_USER] β set to the Kerberos principal of the authenticated client. π
If the -k flag is used, remctld will also set KRB5_KTNAME to the provided keytab path. This is primarily for communication with the GSS-API library, but this setting will also be inherited by any commands run by remctld. π
π EXAMPLES π
remctld is normally started in one of two ways: either as a stand-alone daemon, or via some network management service (for example, systemd or inetd) that handles listening for incoming connections and forking remctld as needed.
To start remctld in stand-alone mode instead, run:
remctld -m
To start remctld in stand-alone mode in the foreground, use:
remctld -F -m
This is a typical invocation with systemd using socket activation. For upstart (with expect stop), use:
remctld -F -m -Z
To start remctld via inetd, add this line to /etc/inetd.conf:
4373 stream tcp nowait root /usr/sbin/tcpd /usr/sbin/remctld
or:
remctl stream tcp nowait root /usr/sbin/tcpd /usr/sbin/remctld
if the remctl service is listed in your /etc/services file. π
Example configuration file:
# Comments can be used like this.
accounts create /usr/local/bin/doaccount /etc/acl/group1 \
/etc/acl/group2
accounts delete /usr/local/bin/doaccount /etc/acl/group3
accounts view /usr/local/bin/doaccount ANYUSER
accounts passwd /usr/local/bin/dopasswd logmask=3 /etc/acl/group1
printing ALL /usr/local/bin/printthing /etc/acl/group2
The commands accounts create, accounts delete, and so forth will all be passed to /usr/local/bin/doaccount with the first argument being the specific subcommand β with the exception of accounts passwd. That command will be passed to /usr/local/bin/dopasswd instead, but it will still get passwd as its first argument. The third argument to accounts passwd (presumably the password π) will not be logged to syslog. All commands starting with printing will be passed to /usr/local/bin/printthing.
Example ACL file:
# This is a comment.
deny:baduser@EXAMPLE.ORG
file:/etc/remctl/acl/admins
principal:service/admin@EXAMPLE.ORG
service/other@EXAMPLE.ORG
This ACL file will reject baduser@EXAMPLE.ORG even if that user would have been allowed by one of the other ACL rules. It will then grant access according to the ACL entries in /etc/remctl/acl/admins and the specific principals service/admin@EXAMPLE.ORG and service/other@EXAMPLE.ORG. The last line takes advantage of the default ACL method of principal when processing an ACL file. β¨
π°οΈ COMPATIBILITY π°οΈ
The version at which various command-line and configuration options and ACL methods were added to remctld are noted in their descriptions. Below is the version information for more general features, in reverse order of when the feature was added.
- Support for the systemd readiness protocol and socket activation, including honoring the environment variables
LISTEN_FDS,LISTEN_PID, andNOTIFY_SOCKET, was added in version 3.7. - Special handling of the
helpandsummarycommands was added in version 3.2. - Support for the
ALLkeyword in the command field of the configuration file was added in version 2.15. (It has always been supported in the subcommand field.) - Support for the
EMPTYkeyword in the subcommand field of the configuration file was added in version 2.15. - Support for ACL schemes and the
method:datasyntax was added in remctl 2.13. Prior versions ofremctldexpected only files in the mainremctldconfiguration file, and only principals or lines starting withincludein those files, without anymethod:prefixes. - The default listening port with the
-moption was changed to the IANA-registered port of 4373 in version 2.11. - Support for IPv6 addresses in the
REMOTE_ADDRenvironment variable was added in version 2.4. remctldused to set the environment variableSCPRINCIPALwhen running commands, for (partial) backward compatibility withsysctld, but stopped doing so in version 2.1.includedirectives in ACL files were added in version 1.11.includedirectives in configuration files were added in version 1.8.
β οΈ CAVEATS β οΈ
When using Heimdal with triple-DES keys and talking to old clients that only speak version one of the remctl protocol, remctld may have problems with MIC verification. This doesn't affect new clients and servers since the version two protocol doesn't use MICs. If you're using Heimdal and run into MIC verification problems, see the COMPATIBILITY section of gssapi(3). π
remctld does not itself impose any limits on the number of child processes or other system resources. You may want to set resource limits in systemd, your inetd server, or the equivalent, or with ulimit when running it as a standalone daemon or under tcpserver. π
Command arguments may not contain NUL characters and must be shorter than the operating system limit on the length of a command line, since they're passed to the command as command-line arguments. The exception is an argument passed via standard input using the stdin= option in the configuration file. At most one argument may be passed that 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. β¨οΈβ¨ iconic honestly
π AUTHOR π
remctld was originally written by Anton Ushakov. Updates and current maintenance are done by Russ Allbery <eagle@eyrie.org>. π«Ά
π COPYRIGHT AND LICENSE π
Copyright 2015-2016, 2018, 2022 Russ Allbery <eagle@eyrie.org>
Copyright 2002-2012, 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 this program is available from its web page at <https://www.eyrie.org/~eagle/software/remctl/>. π
and that's the whole page bestie!! π this one's remctl version 3.18, dated 2022-05-09, and it's the REMCTLD(8) manual β go forth and serve those remote commands responsibly πβ¨
π¦ where this page comes from
- debian bookworm: remctl-server 3.18-1+b7 Β· MIT
- debian trixie: remctl-server 3.18-3 Β· MIT
- ubuntu noble: remctl-server 3.18-1.1build2 Β· MIT
- ubuntu questing: remctl-server 3.18-3
- ubuntu resolute: remctl-server 3.18-5build2 Β· MIT
- ubuntu stonking: remctl-server 3.18-5build3 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms