Friday 24 January 2020

Passwordless SCP/SSH/SFTP from linux to windows server



1. Install OpenSSH-server and client with PowerShell command

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Start-Service sshd

Set-Service -Name sshd -StartupType 'Automatic'


https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

2. Generate public and private key on  linux server with below command

ssh-keygen -t rsa

3. copy content of /<user_home_direcotry>/.ssh/id_rsa.pub

4. Paste the copied data inside windows server C:\Users\<Administrator>\.ssh\authorized_keys

5. Edit C:\Windows\System32\OpenSSH/sshd_config_default and add below lines at bottom


Match User <administrator>
       AuthorizedKeysFile C:\Users\<Administrator>\.ssh\authorized_keys


6. Restart OpenSSH SSH Server Service.

Restart-Service sshd