Updated ssh.exe examples (markdown)

Manoj Ampalam 2018-04-09 11:52:57 -07:00
parent d95db24b83
commit 7ff680bef7

@ -12,31 +12,22 @@
### Usage from client-side (`ssh`)
1. Generate a key pair on the client:
1. Generate a key pair on the client (preferably with a passphrase):
* `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][build13], make sure they are [secured][Secure file].
2. Register [secured][Secure file] private key with ssh-agent (for single sign-on experience)
2. Register private key with ssh-agent (optional, for single sign-on experience)
* `net start ssh-agent`
* `ssh-add id_rsa`
3. Login using [secured][Secure file] private key
3. Login using 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][Secure file] (you may need to re-ACL it) and "NT Service\sshd" has Read access to it
```powershell
$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
```
2. Double check permission on authorized_keys (only System, Administrators and owner can have access).
### For Unix and Linux users
The [Modern Unix Rosetta Stone](https://certsimple.com/rosetta-stone) includes PowerShell examples of common Unix and Linux commands.
[Secure file]: https://github.com/PowerShell/Win32-OpenSSH/wiki/Security-protection-of-various-files-in-win32-openssh
[build13]: https://github.com/PowerShell/Win32-OpenSSH/releases/tag/v0.0.13.0