NetCmdlets 2016
NetCmdlets 2016
Questions / Feedback?

Invoke-SSH Cmdlet

Parameters   Output Objects   Configuration Settings  

The Invoke-SSHcmdlet is used to remotely execute a command on an SSH server.

Syntax

Invoke-SSH [parameters]

Remarks

This cmdlet establishes a Secure Shell (SSH) connection to a server and starts up the user's default shell. Using the cmdlet is very simple. The destination is specified by Server, and both user (default) and public-key authentication is supported. In order to use user authentication, set the Credential parameter. For public-key authentication, first set the AuthMode parameter to 'publickey'. Then set the UserName parameter and specify the certificate with CertStoreType, CertStore, and CertSubject. The cmdlet can also be used by specifying an SSH connection created from the Connect-SSH cmdlet.

Command contains the command you wish to execute on the remote machine. The output of the command is returned in one or more Shell objects. The exit code from the command that is executed will be returned in the LastExitCode variable.

The cmdlets support pipeline input for some of their parameters. Prebuilding an object and piping it to the cmdlet is very useful, but should be used with caution to prevent security conflicts. Steps have been taken to decrease the risk of a possibly accidental pipe to the cmdlet, for instance, the Credential parameter cannot be piped to the cmdlet and must be specified manually.


# execute a command using user authentication.
Invoke-SSH -server SSH_SERVER -credential $mycred -command ls
# execute a command using public key authentication.
Invoke-SSH -server SSH_Server -user myusername -AuthMode publickey -CertStoreType pemkey -CertStore C:\mypath\id_rsa -CertPassword "password" -CertSubject "*" -command ls
# execute a command using an already established SSH connection from the Connect-SSH cmdlet
Invoke-SSH $ssh_connection -command ls
# execute a command using raw shell access instead of SExec
Invoke-SSH -server SSH_SERVER -credential $mycred -command 'ls -l' -EOL "`n" -ShellPrompt = '$ '

Connection Handling

This cmdlet supports persistent connections through the Connection parameter. To establish a new SSH connection, use the Connect-SSH cmdlet. To close the connection, use the Disconnect-SSH cmdlet.

Parameter List


The following is the full list of the parameters of the cmdlet with short descriptions. Click on the links for further details.

ConnectionAn already established connection.
LogFileThe location of a file to which debug information is written.
AuthModeThe type of authentication used by the cmdlet.
CertPasswordThe password to the certificate store.
CertStoreThe name of the certificate store for the client certificate.
CertStoreTypeThe type of certificate store for the client certificate.
CertSubjectThe subject of the certificate used for client authentication.
CommandThe command to be sent to the server.
CompressionAlgorithmsA comma-separated list containing all allowable compression algorithms.
ConfigSpecifies one or more configuration settings.
CredentialThe PSCredential object to use for user/password authentication.
EncryptionAlgorithmsA comma-separated list containing all allowable compression algorithms.
EOLThe end of line character to use for parsing the response.
FirewallHostName or IP address of firewall.
FirewallPasswordA password if authentication is to be used when connecting through the firewall.
FirewallPortThe port of the firewall to which to connect.
FirewallTypeDetermines the type of firewall to connect through.
FirewallUserA user name if authentication is to be used connecting through a firewall.
ForceForces the cmdlet to accept the default behavior instead of querying the user.
LocalIPThe IP address of the local interface to use.
LogFileThe location of a file to which debug information is written.
PasswordThe password to use for authentication.
PasswordPromptThe shell prompt used for keyboard-interactive authentication.
PortThe port to be used.
ServerThe address of the Server.
ShellPromptSpecifies the shell prompt to wait for.
ShellPromptExpressionA regular expression to match the shell prompt returned by the server.
SSHAcceptThe hex-encoded fingerprint of the host to trust explicitly.
StdinThe text to feed the expression/command on the standard input stream.
TimeoutThe maximum time allowed for the operation.
UserThe username to use for authentication.

Output Objects


The following is the full list of the output objects returned by the cmdlet with short descriptions. Click on the links for further details.

ShellObject containing stdout data returned from the Server .

Configuration Settings


The following is a list of configuration settings for the cmdlet with short descriptions. Click on the links for further details.

SexecExitStatusVarThe name of a variable to store the exit status of a command executed via the SExec protocol.
TerminalHeightThe height of the terminal display.
TerminalWidthThe width of the terminal display.
TerminalUsePixelWhether the terminal's dimensions are in columns/rows or pixels.
TerminalModesThe terminal mode to set when communicating with the SSH host.
EncodedTerminalModesThe terminal mode to set when communicating with the SSH host.
TerminalHeightThe height of the terminal display.
TerminalWidthThe width of the terminal display.
TerminalUsePixelWhether the terminal's dimensions are in columns/rows or pixels.
ClientSSHVersionStringThe SSH version string used by the cmdlet.
SignedSSHCertThe CA signed client public key used when authenticating.
SSHAcceptServerCAKeyThe CA public key that signed the server's host key.
SSHAcceptAnyServerHostKeyIf set the cmdlet will accept any key presented by the server.
SSHAcceptServerHostKeyFingerPrintThe fingerprint of the server key to accept.
SSHKeyExchangeAlgorithmsSpecifies the supported key exchange algorithms.
SSHMacAlgorithmsSpecifies the supported Mac algorithms.
SSHPublicKeyAlgorithmsSpecifies the supported public key algorithms.
SSHKeepAliveIntervalThe interval between keep alive packets.
SSHKeepAliveCountMaxThe maximum number of keep alive packets to send without a response.
SSHKeyRenegotiateCauses the component to renegotiate the SSH keys.
KeyRenegotiationThresholdSets the threshold for the SSH Key Renegotiation.
SSHPubKeyAuthSigAlgorithmsSpecifies the signature algorithm when attempting public key authentication.
KerberosRealmThe fully qualified domain name of the Kerberos Realm to use for GSSAPI authentication.
KerberosDelegationIf true, asks for credentials with delegation enabled during authentication.
KerberosSPNThe Kerberos Service Principal Name of the SSH host.
LogSSHPacketsIf true, detailed SSH packet logging is performed.
MaxPacketSizeThe maximum packet size of the channel, in bytes.
MaxWindowSizeThe maximum window size allowed for the channel, in bytes.
PasswordPromptThe text of the password prompt used in keyboard-interactive authentication.
PreferredDHGroupBitsThe size (in bits) of the preferred modulus (p) to request from the server.
RecordLengthThe length of received data records.
ConnectionTimeoutSets a separate timeout value for establishing a connection.
FirewallAutoDetectTells the cmdlet whether or not to automatically detect and use firewall system settings, if available.
FirewallHostName or IP address of firewall (optional).
FirewallPasswordPassword to be used if authentication is to be used when connecting through the firewall.
FirewallPortThe TCP port for the FirewallHost;.
FirewallTypeDetermines the type of firewall to connect through.
FirewallUserA user name if authentication is to be used connecting through a firewall.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
LingerWhen set to True, connections are terminated gracefully.
LingerTimeTime in seconds to have the connection linger.
LocalHostThe name of the local host through which connections are initiated or accepted.
LocalPortThe TCP port in the local host where the cmdlet binds.
MaxLineLengthThe maximum amount of data to accumulate when no EOL is found.
MaxTransferRateThe transfer rate limit in bytes per second.
TCPKeepAliveDetermines whether or not the keep alive socket option is enabled.
UseIPv6Whether to use IPv6.
TcpNoDelayWhether or not to delay when sending packets.
AbsoluteTimeoutDetermines whether timeouts are inactivity timeouts or absolute timeouts.
FirewallDataUsed to send extra data to the firewall.
InBufferSizeThe size in bytes of the incoming queue of the socket.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
CodePageThe system code page used for Unicode to Multibyte translations.

 
 
Copyright (c) 2017 /n software inc. - All rights reserved.
NetCmdlets 2016 - Version 16.0 [Build 6335]