--- title: "Command Line Interface (CLI) Actions" slug: "command-line-interface-cli-actions" description: "This is a list of actions that can be used in RapidIdentity Connect to interact with the Command Line Interface (CLI) of a system." tags: ["RapidIdentity ", "Connect", "Actions", "Command Line Interface (CLI)"] updated: 2022-06-03T15:01:41Z published: 2022-06-03T15:01:41Z canonical: "help.rapididentity.com/command-line-interface-cli-actions" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.rapididentity.com/llms.txt > Use this file to discover all available pages before exploring further. # Command Line Interface CLI Actions ## Command Line Interface (CLI) Actions ### openRemoteCLI Open an SSH connection to a remote system. | Property | Value | Description | | --- | --- | --- | | host* | text, expression, variable | the remote host name or address | | port | expression, variable | the remote port (default: 22) | | user* | text, expression, variable | the username for remote host | | password* | password, string, expression, variable | the password for remote host | | options | expression, variable | the value of the ciphers (allowed encryption algorithms), macs (allowed hashing algorithms), or whether to allow debugging to facilitate troubleshooting (debug: true) | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript session = openRemoteCLI("host1.acme.org", 22, "root","password") close(session) ``` ### openRemoteCLIWithCert Open an SSH connection to a remote system using public/private key authentication. | Property | Value | Description | | --- | --- | --- | | host* | text, expression, variable | the remote host name or address | | port | expression, variable | the remote port (default: 22) | | user* | text, expression, variable | the username for remote host | | privateKey* | text, expression, variable | the path of the private key file within the project file store or the private key loaded as a byte array | | publicKey | text, expression, variable | the path of the public key file within the project file store or the public key loaded as a byte array (default: none) | | passPhrase | password, string, expression, variable | the passPhrase for private key (default: none) | | options | expression, variable | the value of the ciphers (allowed encryption algorithms), macs (allowed hashing algorithms), or whether to allow debugging to provide more information to facilitate troubleshooting (debug: true) | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript # assumes public and private key have been uploaded to project files store, # and public key has been added as a trusted identity on SSH remote server session = openRemoteCLIWithCert("host1.acme.org", 22, "root", "/.ssh/id_rsa", "/.ssh/id_rsa.pub", ) close(session) ``` ### openRemoteWindowsCLI Open a CLI connection to a remote Windows system. | Property | Value | Description | | --- | --- | --- | | host* | text, expression, variable | the remote host name or address | | user* | text, expression, variable | the username for remote host (must be an administrator) | | domain* | text, expression, variable | the domain for the user | | password* | password, string, expression, variable | the password for remote host | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript session = openRemoteWindowsCLI("windows.acme.org", "Administrator", "ACME", ) close(session) ``` ### quoteCLIParam Quote a CLI command parameter so that no characters have special meaning to the CLI interpreter. | Property | Value | Description | | --- | --- | --- | | param* | text, expression, variable | the command parameter to quote | | method* | choice (cmd, powershell, sh), text, expression, variable | the cli quoting method | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript # open file with windows local users to create varNewUsersInput = openDelimitedTextInput(newwindowslocalusers.csv, "username, givenName, surname, password") varSession = openRemoteWindowsCLI("windows.acme.org", "Administrator", "ACME", ) close(session) forEach(varNewUserRecord, newUsersInput) { # quote the dynamic data for use with powershell varQuotedUsername = quoteCLIParam(varNewUserRecord[\'username\'], "powershell") varQuotedFullName = quoteCLIParam(varNewUserRecord[\'givenName\'] + " " + varNewUserRecord[\'surname\'], "powershell") varQuotedPassword = quoteCLIParam(varNewUserRecord[\'username\'], "powershell") # build the powershell command using the quoted data varPSCommand = "$Computer = [ADSI]\\"WinNT://$Env:COMPUTERNAME, Computer\\"" varPSCommand = $varPSCommand + ";$LocalAdmin = $Computer.Create (\'User\" + varQuotedUsername + ")" varPSCommand = $varPSCommand + ";$LocalAdmin.SetPassword (" + varQuotedPassword + ")"\n varPSCommand = $varPSCommand + ";$LocalAdmin.SetFullName(" + varQuotedQuotedFullname + ")" varPSCommand = varPSCommand + ";$LocalAdmin.UserFlags = 64 + 65536" varPSCommand = varPSCommand + ";$LocalAdmin.SetInfo()" # quote the entire powershell command for cmd varQuotedPSCommand = quoteCLIParam(varPSCommand, "cmd") runRemoteCLICommand(varSession, "powershell -command " + varQuotedPSCommand) } close(varSession) close(varNewUsersInput) ``` ### runCLICommand Run a CLI command. Returns a record with 3 fields: exitStatus, output, and error. | Property | Value | Description | | --- | --- | --- | | command* | text, expression, variable | the command to run | | input | text, expression, variable | a string to feed to the command as standard input (default: none) | | env | expression, variable | a Record containing environment variables to set (default: none) | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript result = runCLICommand("date") # Should return current date/time log(, u"result['output']", ) ``` ### runRemoteCLICommand Run a CLI command on a remote system. Returns a record with 3 fields: exitStatus, output, and error. | Property | Value | Description | | --- | --- | --- | | remoteCLI* | expression, variable | the remote CLI connection | | command* | text, expression, variable | the command to run. | | input | text, expression, variable | a string to feed to the command as standard input (default: none) | | env | expression, variable | a Record containing environment variables to set (default: none) | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript session = openRemoteCLI("host1.acme.org","root","password") result = runRemoteCLICommand(session,"date") close(session) # Should return current date/time log(, u"result['output']", ) ```