Skip to content

ssh.exe examples

bagajjal edited this page May 24, 2017 · 38 revisions

Login With Password

  1. Workgroup users
    • ssh user@host
  2. Domain users: Domain needs to be explicitly specified. Any of the following formats work
    • ssh -l user@domain host
    • ssh domain\user@host
    • ssh user@domain@host

Login With SSH Keys

Usage from client-side (ssh)

  1. Generate a key pair on the client:
    • ssh-keygen -t rsa -f id_rsa
    • If you're using an existing key pair generated by ssh-keygen before installing build v0.0.13.0, make sure they are secured.
  2. Register secured private key with ssh-agent (for single sign-on experience)
    • net start ssh-agent
    • ssh-add id_rsa
  3. Login using secured private key
    • ssh -i .\id_rsa user@host (workgroup user)
    • ssh -i .\id_rsa -l user@domain host (domain user)

Setup server-side (sshd)

  1. Copy id_rsa.pub (client's public key) to corresponding user's directory on the SSH server at %systemdrive%\Users\<user>\.ssh\authorized_keys
  2. Make sure the authorized_keys file is secured (you may need to re-ACL it) and "NT Service\sshd" has Read access to it
$authorizedKeyPath = "%systemdrive%\users\<user>\.ssh\authorized_keys"
$acl = Get-Acl $authorizedKeyPath
$ar = New-Object System.Security.AccessControl.FileSystemAccessRule("NT Service\sshd", "Read", "Allow")
$acl.SetAccessRule($ar)
Set-Acl $authorizedKeyPath $acl

For Unix and Linux users

The Modern Unix Rosetta Stone includes PowerShell examples of common Unix and Linux commands.

Clone this wiki locally