jessemoore

InstallSSH-Win

Sep 27th, 2020 (edited)
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Windows SSH client /  Server
  2. # https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
  3. #
  4. # Check for installed
  5. Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
  6. #
  7. # Install the OpenSSH Client
  8. #Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
  9.  
  10. # Install the OpenSSH Server
  11. Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
  12.  
  13. # Both of these should return the following output:
  14.  
  15. #Path          :
  16. #Online        : True
  17. #RestartNeeded : False
  18.  
  19. # Uninstall the OpenSSH Client
  20. #Remove-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
  21.  
  22. # Uninstall the OpenSSH Server
  23. #Remove-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
  24.  
  25. Start-Service sshd
  26. # OPTIONAL but recommended:
  27. Set-Service -Name sshd -StartupType 'Automatic'
  28. # Confirm the Firewall rule is configured. It should be created automatically by setup.
  29. Get-NetFirewallRule -Name *ssh*
  30. # There should be a firewall rule named "OpenSSH-Server-In-TCP", which should be enabled
  31. # If the firewall does not exist, create one
  32. New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
  33.  
  34. #  sets the default shell to be PowerShell.exe
  35. New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force
  36. #cd ~\.ssh\
  37. #ssh-keygen
  38.  
  39. # Deprecated opensshutils, see below alternative
  40. # https://github.com/PowerShell/Win32-OpenSSH/wiki/Security-protection-of-various-files-in-Win32-OpenSSH
  41.  
  42. # Key management https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_keymanagement
  43. # Make sure that the .ssh directory exists in your server's home folder
  44. #ssh user1@domain1@contoso.com mkdir C:\users\user1\.ssh\
  45.  
  46. # Use scp to copy the public key file generated previously to authorized_keys on your server
  47. #scp C:\Users\user1\.ssh\id_ed25519.pub user1@domain1@contoso.com:C:\Users\user1\.ssh\authorized_keys
  48.  
  49. # Appropriately ACL the authorized_keys file on your server
  50. #ssh --% user1@domain1@contoso.com powershell -c $ConfirmPreference = 'None'; Repair-AuthorizedKeyPermission #C:\Users\user1\.ssh\authorized_keys
Add Comment
Please, Sign In to add comment