RemoteRun

RemoteRun["host","command"]

runs the specified operating system command on the remote host, returning the exit code obtained.

RemoteRun[IPAddress["address"],"command"]

runs the command on the machine with the specified IP address.

RemoteRun[obj,"command"]

run the command on the remote host specified by the RemoteConnectionObject obj.

Details and Options

  • RemoteRun["host","command"] by default prompts for a username and password.
  • RemoteRun["user@host",] prompts for a password only.
  • RemoteRun will use an ssh-agent for authentication if available.
  • RemoteRun allows the following options:
  • Authentication$SSHAuthenticationauthentication parameters for the connection
    RemoteAuthorizationCachingFalsewhether to use remote authorization caching
  • In the form Authentication->assoc, the association assoc can contain these keys:
  • "Username"username to use for authentication
    "Password"password to use for authentication
    "SSHKey"SSH identity
    "SSHKeyPassword"passphrase string to use to decrypt SSHKey
  • An SSH identity can be given in the form "SSHKey"->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.
  • RemoteRun returns the error code of the remote "command".

Examples

open allclose all

Basic Examples  (3)

Run a Wolfram script located on the remote host:

Append text to a file on the remote host:

Check the contents of that file using RemoteRunProcess:

Run a command that will return an exit code:

Scope  (1)

Create a persistent session with RemoteConnect:

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

Close the session:

Options  (4)

Authentication  (3)

Run a remote command using username and password authentication:

Run a remote command using an identity file for authentication:

Set a value for $SSHAuthentication:

Now commands can be run using the default authentication contained in $SSHAuthentication:

RemoteAuthorizationCaching  (1)

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

The user is now authorized to execute commands without authentication:

Possible Issues  (1)

RemoteRun prompts for a username and password. If neither is provided, RemoteRun issues a warning message and returns $Failed:

If either the username or password is entered incorrectly, RemoteRun issues a warning message and returns $Failed:

If a remote machine cannot be found on the network, RemoteRun issues a warning message and returns $Failed:

Introduced in 2018
 (11.3)