Windows
Most of the stuff here is Python3 related.
Table of contents
Setup OpenSSH Server
Public Key Authentication
I got these instructions from: https://www.concurrency.com/blog/may-2019/key-based-authentication-for-openssh-on-windows
- Create the file
C:\ProgramData\ssh\administrators_authorized_keys
- Add your public key inside of it
- Run the following Powershell script to fix the permissions to the file:
$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys
$acl.SetAccessRuleProtection($true, $false)
$administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule("Administrators","FullControl","Allow")
$systemRule = New-Object system.security.accesscontrol.filesystemaccessrule("SYSTEM","FullControl","Allow")
$acl.SetAccessRule($administratorsRule)
$acl.SetAccessRule($systemRule)
$acl | Set-Acl
Permissions for Powershell scripts
If you try to run a Powershell script and get an error like the following:
.\fix-permissions.ps1 : File C:\ProgramData\ssh\fix-permissions.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170
The solution is to fix the permissions for the current user.
Open a Powershell session and type:
PS C:\ProgramData\ssh> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined
PS C:\ProgramData\ssh> Get-ExecutionPolicy -Scope CurrentUser Undefined
As seen above, the ExecutionPolicy
for the CurrentUser
is set to undefined and so that user cannot execute powershell scripts. To fix it, do the following:
PS C:\ProgramData\ssh> Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted