Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Launch pwsh and -
- $RemoteHostNameOrIP = "zerotesting5.zero.lab"
- $SSHUserName = "zeroadmin@zero"
- $LocalPortForSSHTunnel = 5998
- $RemoteSSHPort = 22
- putty -ssh $RemoteHostNameOrIP -l $SSHUserName -L $LocalPortForSSHTunnel`:$RemoteHostNameOrIP`:$RemoteSSHPort
- The above will launch a putty window where you'll have to enter your password, unless you have a key loaded in pageant. If you don't have pageant, but have a .ppk key available on your filesystem, you can do:
- putty -ssh $RemoteHostNameOrIP -l $SSHUserName -i $SSHKeyPath -L $LocalPortForSSHTunnel`:$RemoteHostNameOrIP`:$RemoteSSHPort
- Create a New PSSession -
- New-PSSession -HostName localhost:5998
- If you don't have an ssh key loaded into the OpenSSH-Win64 ssh-agent service (which is completely separate from putty), you'll get a password prompt:
- zeroadmin@ZERO@localhost's password:
- Id Name Transport ComputerName ComputerType State ConfigurationName Availability
- -- ---- --------- ------------ ------------ ----- ----------------- ------------
- 3 Runspace2 SSH localhost RemoteMachine Opened DefaultShell Available
- Then test the PSSession to make sure you're on your Remote Host:
- PS C:\Users\zeroadmin> Invoke-Command -Session $(Get-PSSession -Id 3) -ScriptBlock {$env:ComputerName}
- ZEROTESTING5
- Cool!
Add Comment
Please, Sign In to add comment