({{, (RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess])["host","command"]
runs the specified system command on the remote host, returning information on the outcome.}, {, (RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess])[(RefLink[IPAddress, paclet:ref/IPAddress])["address"],"command"]
runs the command on the machine with the specified IP address.}, {, (RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess])[obj,"command"]
run the command on the remote host specified by the (RefLink[RemoteConnectionObject, paclet:ref/RemoteConnectionObject]) obj.}, {, (RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess])["host",{"command",(Subscript[arg, 1]),(Subscript[arg, 2]),…}]
runs the specified command, with command-line arguments (Subscript[arg, i]).}, {, (RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess])["host", command,"prop"]
returns only the specified property.}, {, (RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess])["host", command,prop,input]
feeds the specified initial input to the command.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess]) returns an association with the process exit code, the standard output and the standard error.

(RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess])["host",…] prompts for a username and password.

(RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess])["user@host",…] prompts for a password only.

(RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess]) will use an ssh-agent for authentication if available.

In (RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess])[command,prop,input], input is automatically converted to a string using (RefLink[ToString, paclet:ref/ToString]). The same is true for the (Subscript[arg, i]) in (RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess])[{command,(Subscript[arg, 1]),…},…].

Typical possible properties to return include:

(RefLink[RemoteRunProcess, paclet:ref/RemoteRunProcess]) allows the following options:

In the form (RefLink[Authentication, paclet:ref/Authentication])->assoc, the association assoc can contain these keys:

An SSH identity can be given in the form "SSHKey"->(RefLink[File, paclet:ref/File])[ident], where ident is a file containing an SSH private key. It can also be given as "SSHKey"->"string", where "string" is an SSH private key.

OpenersPrimaryExamplesSection(Spacer1)Examples  (6)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Evaluate the hostname command on a remote machine:

RemoteRunProcess["host.example.com" , "hostname"]

Use a specific username to run the uptime command:

RemoteRunProcess["username@host.example.com","uptime"]

Retrieve a specified property from a command:

RemoteRunProcess["host.example.com","hostname", "StandardOutput"]

Provide input to a command:

RemoteRunProcess["host.example.com","cat", All, "Hello World!"]

Create a persistent session with (RefLink[RemoteConnect, paclet:ref/RemoteConnect]):

remote = RemoteConnect["host.example.com"]

Once the session is created, it can be used without having to reconnect:

RemoteRunProcess[remote , "hostname"]

Close the session:

DeleteObject[remote]

OpenersExampleSection1(Spacer1)Scope  (1)

Obtain the exit code from a command:

RemoteRunProcess["username@host.example.com" , {"sh", "-c", "'exit 113'"},"ExitCode"]

Start a process asynchronously. When it is done, read from the log:

RemoteRunProcess["username@host.example.com" , "date > log.txt &"]

RemoteRunProcess["user@host.example.com" , "cat log.txt"]

OpenersExampleSection2(Spacer1)Options  (4)

OpenersExampleSubsection0(Spacer1)Authentication  (3)

Run a remote process using username and password authentication:

RemoteRunProcess["host.example.com" , "pwd",Authentication-><|"Username"->"user", "Password"->"xxxxx"|>]

Run a remote process using an identity file for authentication:

RemoteRunProcess["host.example.com" , "pwd",Authentication-><|"Username"->"user", "SSHKey"->File["/path/.ssh/id_rsa"]|>]

Set a value for (RefLink[$SSHAuthentication, paclet:ref/$SSHAuthentication]):

$SSHAuthentication=<|"Username"->"user", "Password"->password|>

Now processes can be run using the default authentication contained in (RefLink[$SSHAuthentication, paclet:ref/$SSHAuthentication]):

RemoteRunProcess["host.example.com" , "date"]

OpenersExampleSubsection1(Spacer1)RemoteAuthorizationCaching  (1)

Authorize future connections by placing the public key on the remote machine:

RemoteRunProcess["username@host.example.com" , "date", RemoteAuthorizationCaching->True]

This user is now authorized to execute commands without authentication:

RemoteRunProcess["username@host.example.com" , "date"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[RemoteRun, paclet:ref/RemoteRun])  ▪  (RefLink[RunProcess, paclet:ref/RunProcess])  ▪  (RefLink[Run, paclet:ref/Run])  ▪  (RefLink[RemoteConnect, paclet:ref/RemoteConnect])  ▪  (RefLink[CopyFile, paclet:ref/CopyFile])  ▪  (RefLink[$SSHAuthentication, paclet:ref/$SSHAuthentication])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Calling External Programs, paclet:guide/CallingExternalPrograms])}, {▪(RefLinkPlain[Direct Control of External Processes, paclet:guide/DirectControlOfExternalProcesses])}, {▪(RefLinkPlain[External Operations, paclet:guide/ExternalOperations])}})}})