Format an ssh connection command and connect to a target server, using a target account via CyberArk PSMP or SIA.
| Main Branch | Dev Branch | CodeFactor | Coverage | PowerShell Gallery | License |
|---|---|---|---|---|---|
New-PSMPSession -VaultUser pspete -TargetAccount root -TargetAddress server -TargetPort 2222 -PSMPAddress psmp
# pspete@root@server#2222@psmp
New-PSMPSession -VaultUser pspete -TargetAccount root -TargetAddress server -TargetPort 22 -TunnelPort 5432 -PSMPAddress psmp -SSHArgument '-L', '5432:127.0.0.1:5432'
# ssh -L 5432:127.0.0.1:5432 pspete@root@server#22#5432@psmpNew-PSMPSession -VaultUser pspete -TargetAccount root -TargetAddress server -PSMPAddress psmp -SSHArgument '-t' -Command 'uptime'
# ssh -t pspete@root@server@psmp uptime
New-PSMPSession -VaultUser pspete -TargetAccount root -TargetAddress server -PSMPAddress psmp -SSHArgument '-i', 'C:\keys\psmp_key'
# ssh -i C:\keys\psmp_key pspete@root@server@psmpSpecify each ssh switch and its value as separate array elements ('-i', 'C:\keys\psmp_key', not '-i C:\keys\psmp_key').
An SSH key supplied with -i authenticates you to PSMP / the SIA gateway (e.g. an MFA caching key), not to the target.
Import-Csv .\targets.csv | New-PSMPSession -VaultUser pspete -PSMPAddress psmpUse -WhatIf or -Debug with either function to view the connection string without connecting.
Connect through CyberArk Secure Infrastructure Access (SIA). Supplying -TargetAccount uses vaulted access; omitting it uses zero standing privileges (ZSP).
New-SIASession -User pete@pspete.dev -Subdomain acme -TargetAddress 10.0.0.5
# pete@pspete.dev#acme@10.0.0.5@acme.ssh.cyberark.cloud
New-SIASession -User pete@pspete.dev -Subdomain acme -TargetAddress 10.0.0.5 -TargetPort 2222 -NetworkName Net1
# pete@pspete.dev#acme@10.0.0.5:2222#Net1@acme.ssh.cyberark.cloudNew-SIASession -User pete@pspete.dev -Subdomain acme -TargetAccount root -TargetAddress server.pspete.dev
# pete@pspete.dev#acme@root@server.pspete.dev@acme.ssh.cyberark.cloud
New-SIASession -User pete@pspete.dev -Subdomain acme -TargetAccount admin -TargetDomain pspete.dev -TargetAddress server.pspete.dev
# pete@pspete.dev#acme@admin#pspete.dev@server.pspete.dev@acme.ssh.cyberark.cloudNew-SIASession -User pete@pspete.dev -Subdomain acme -TargetAddress 10.0.0.5 -Gateway ssh.vanity.example.com
# pete@pspete.dev#acme@10.0.0.5@ssh.vanity.example.com
New-SIASession -User pete@pspete.dev -Subdomain acme -TargetAddress 10.0.0.5 -SSHArgument '-L', '8080:10.0.0.5:80' -Command 'touch tmp.txt; cat tmp.txt'
# ssh -L 8080:10.0.0.5:80 pete@pspete.dev#acme@10.0.0.5@acme.ssh.cyberark.cloud 'touch tmp.txt; cat tmp.txt'
New-SIASession -User pete@pspete.dev -Subdomain acme -TargetAddress 10.0.0.5 -SSHArgument '-i', 'C:\keys\sia_key'
# ssh -i C:\keys\sia_key pete@pspete.dev#acme@10.0.0.5@acme.ssh.cyberark.cloudDownload an SIA MFA caching SSH key, then use it with New-SIASession to connect without repeating MFA until the key expires.
$Key = Save-SIASSHKey -User pete@pspete.dev -Subdomain acme -Path ~\.ssh\acme_pete
# sftp pete@pspete.dev#acme@key@acme.ssh.cyberark.cloud:/key C:\Users\pete\.ssh\acme_pete
New-SIASession -User pete@pspete.dev -Subdomain acme -TargetAddress 10.0.0.5 -SSHArgument '-i', $Key.FullName
Save-SIASSHKey -User pete@pspete.dev -Subdomain acme -Path ~\.ssh\acme_pete.ppk -Format PPK
# sftp pete@pspete.dev#acme@key_ppk@acme.ssh.cyberark.cloud:/key C:\Users\pete\.ssh\acme_pete.ppkAccess to the saved key is restricted to the current user. SIA only accepts the key from the IP address it was downloaded from.
- PowerShell Core or Powershell v5.1 (minimum).
- SSH Client (and SFTP client for
Save-SIASSHKey) installed and configured on your PATH - Target account to connect to a target server through CyberArk PSMP.
Use one of the following methods:
PowerShell 5.0 or above must be used
This is the simplest & preferred method for installation of the module.
To install the module from the PowerShell Gallery,
from a PowerShell prompt, run:
Install-Module -Name PSMPSession -Scope CurrentUser
You can manually copy the module files to one of your powershell module folders.
Find your PowerShell Module Paths with the following command:
$env:PSModulePath.split(';')
The module files should be placed in a folder named PSMPSession in one of the listed locations.
More: about_PSModulePath
There are multiple options for downloading the module files:
- Download from the module PowerShell Gallery:
- Run the PowerShell command
Save-Module -Name PSMPSession -Path C:\temp - Copy the
C:\temp\PSMPSessionfolder to your "Powershell Modules" directory of choice.
- Run the PowerShell command
- Download the latest release
- Unblock & Extract the archive
- Rename the extracted
PSMPSession-v#.#.#folder toPSMPSession - Copy the
PSMPSessionfolder to your "Powershell Modules" directory of choice.
- Download the
main branch- Unblock & Extract the archive
- Copy the
PSMPSession(\<Archive Root>\PSMPSession-main\PSMPSession) folder to your "Powershell Modules" directory of choice.





