Click or drag to resize

LinuxSshProxy Class

Uses a SSH/SCP connection to provide access to Linux machines to access files, run commands, etc.

Inheritance Hierarchy

Namespace:  Neon.SSH
Assembly:  Neon.SSH (in Neon.SSH.dll) Version: 2.14.0
Syntax
public class LinuxSshProxy : IDisposable

The LinuxSshProxy type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyAddress
The cluster private IP address to used for connecting to the remote machine.
Public propertyConnectTimeout
The connection attempt timeout. This defaults to 5 seconds.
Public propertyDefaultRunOptions
Specifies the default options to be bitwise ORed with any specific options passed to a run or sudo execution command when the Defaults flag is specified. This defaults to None.
Public propertyDownloadFolderPath
Returns the path to the user's download folder on the remote machine.
Public propertyFileTimeout
The file operation timeout. This defaults to 30 seconds.
Public propertyHomeFolderPath
Returns the path to the user's home folder on the remote machine.
Public propertyIsFaulted
Indicates that the remote machine is in a faulted state because one or more operations have failed.
Public propertyIsReady
Indicates that the remote machine has completed or has failed the current set of operations.
Public propertyName
Returns the display name for the remote machine.
Public propertyOsName

Returns the name of the remote operating system (e.g. "Ubuntu").

Note Note
This is only valid after a connection has been established.
Public propertyOsVersion

Returns the version of the remote operating system (e.g. "18.04.1").

Note Note
This is only valid after a connection has been established.
Public propertyRemotePath
The PATH to use on the remote machine when executing commands in the session or null/empty to run commands without a path. This defaults to the standard Linux path.
Public propertyRetryCount
The number of times to retry a failed remote command. This defaults to 5.
Public propertySshPort
The SSH port. This defaults to 22.
Public propertyStatus
The current remote machine status.
Public propertyUploadFolderPath
Returns the path to the user's upload folder on the remote machine.
Public propertyUsername
Returns the username used to log into the remote node.
Top
Methods
  NameDescription
Public methodClone
Returns a clone of the SSH proxy. This can be useful for situations where you need to be able to perform multiple SSH/SCP operations against the same machine in parallel.
Public methodCloneScpClient

Creates and returns a clone of a low-level ScpClient to the remote endpoint.

Note Note
The caller is responsible for disposing the returned instance.
Public methodCloneSshClient

Creates and returns a clone of a low-level SshClient to the remote endpoint.

Note Note
The caller is responsible for disposing the returned instance.
Protected methodCloneTo
Used by derived classes to copy the base class state to a new instance as well as configure the new connection's SSH and SCP clients.
Public methodConnect
Establishes a connection to the remote machine, disconnecting first if the proxy is already connected.
Public methodCreateShell
Creates an interactive shell.
Public methodCreateSudoShell
Creates an interactive shell for running with sudo permissions.
Public methodDirectoryExists
Determines whether a directory exists on the remote server.
Public methodDisableSudoPrompt

Prevents sudo from prompting for passwords and also ensures that the /home/root directory exists and has the appropriate permissions.

Note Note
The connected user must already be a member of the root group.
Public methodDisconnect
Closes any open connections to the Linux remote machine but leaves open the opportunity to reconnect later.
Public methodDispose
Releases all associated resources (e.g. any open remote machine connections).
Protected methodDispose(Boolean)
Releases all associated resources (e.g. any open remote machine connections).
Public methodDownload(String, Stream)
Downloads a file from the Linux server and writes it out a stream.
Public methodDownload(String, String)
Downloads a file from the remote node to the local file computer, creating parent folders as necessary.
Public methodDownloadBytes
Downloads a file as bytes from the Linux server .
Public methodDownloadText
Downloads a file as text from the Linux server.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodFault
Puts the node proxy into the faulted state.
Public methodFileExists
Determines whether a file exists on the remote server.
Protected methodFinalize
Finalizer.
(Overrides ObjectFinalize.)
Protected methodGetAuthenticationMethod
Extracts the authentication method from SSH credentials.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetNeonInitStatus
Returns an indication of whether the neon-init service has been executed on the remote machine. This service is deployed to neonKUBE cluster nodes to act as a poor-man's cloud-init to configure the network and credentials by mounting a virual ISO drive with a configuration script for non-cloud environments.
Public methodGetNetworkInterface
Returns the name of the network interface assigned to a specific IP address.
Public methodGetTimeUtc
Returns the current time (UTC) on the remote machine.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodKubectlApply
Uses kubectl apply -f to apply a YAML file.
Public methodKubeCtlApply
Uses kubectl apply -f to apply a YAML file.
Public methodListDisks
Lists information about the disks on the remote machine.
Public methodListPartitionedDisks
Returns the names of any partitioned disks (excluding floppy disks).
Public methodListUnpartitionedDisks
Returns the names of any unpartitioned disks (excluding floppy disks).
Public methodLog
Writes text to the operation log.
Public methodLogException(Exception)
Writes exception information to the operation log.
Public methodLogException(String, Exception)
Writes exception information to the operation log.
Public methodLogFlush
Flushes the log.
Public methodLogLine
Writes a line of text to the operation log.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodReboot
Reboot the remote machine.
Public methodRemoveFile
Removes a file on the server if it exists.
Public methodRunCommand(String, Object)
Runs a shell command on the Linux server.
Public methodRunCommand(CommandBundle, RunOptions)
Runs a CommandBundle with user permissions on the remote machine.
Public methodRunCommand(String, RunOptions, Object)
Runs a shell command on the Linux server with RunOptions.
Public methodSetNeonInitStatus
Manually sets the neon-init service execution status.
Public methodShutdown
Shutdown the remote machine.
Public methodSudoCommand(String, Object)
Runs a shell command on the Linux server under sudo.
Public methodSudoCommand(CommandBundle, RunOptions)
Runs a CommandBundle under sudo on the remote machine.
Public methodSudoCommand(String, RunOptions, Object)
Runs a shell command on the Linux server under sudo with RunOptions.
Public methodSudoCommandAsUser(String, String, Object)
Runs a shell command on the Linux server under sudo as a specific user.
Public methodSudoCommandAsUser(String, String, RunOptions, Object)
Runs a shell command on the Linux server under sudo as a specific user and with RunOptions.
Public methodToString
Returns a string that represents the current object.
(Overrides ObjectToString.)
Public methodUpdateCredentials
Updates the proxy credentials. Call this whenever you change the password or SSH certificate for the user account we're using for the current proxy connection. This ensures that the proxy will be able to reconnect to the service when required.
Public methodUpload
Uploads a binary stream to the Linux server and then writes it to the file system.
Public methodUploadBytes
Uploads a byte array to a Linux server file.
Public methodUploadText(String, String, Int32, Encoding, String, String)
Uploads a text string to the Linux server and then writes it to the file system, converting any CR-LF line endings to the Unix-style LF.
Public methodUploadText(String, StringBuilder, Int32, Encoding, String, String)
Uploads text from a StringBuilder to the Linux server and then writes it to the file system, converting any CR-LF line endings to the Unix-style LF.
Public methodUploadText(String, Stream, Int32, Encoding, Encoding, String, String)
Uploads a text stream to the Linux server and then writes it to the file system, converting any CR-LF line endings to the Unix-style LF.
Public methodVerifyCertificate
Verifies a TLS/SSL certificate.
Public methodWaitForBoot
Waits for the remote machine to boot by continuously attempting to establish a SSH session.
Top
Fields
  NameDescription
Protected fieldcredentials
Protected fieldlogWriter
Public fieldStatic memberSshProxyInitPath
Path to the file whose existence indicates that the proxy has already configured things like disabling SUDO password prompts.
Top
Remarks

This class includes methods to invoke Linux commands on the node,

Call Dispose or Disconnect to close the connection.

Note Note
You can use Clone to make a copy of a proxy that can be used to perform parallel operations against the same machine.
Thread Safety
Instance members of this type are not safe for multi-threaded operations.
See Also