How to use ssh and scp in Windows

Contents

| Windows Server 2019

Run Powershell as an administator and generate private and public keys

ssh-keygen -trsa -b2048

Check that files exists

ls $env:USERPROFILE\.ssh

Add public key

type $env:USERPROFILE\.ssh\id_rsa.pub | ssh root@192.168.131.10 "cat >> .ssh/authorized_keys"

Check connect without password

ssh root@192.168.131.10

Check that commands are runned

ssh root@192.168.131.10 "cat /etc/*release"

Put the file into /tmp

scp "$env:USERPROFILE\.ssh\id_rsa.pub" "root@192.168.131.10:/tmp/"

Put several files into /tmp

scp -r "C:\tmp" "root@192.168.131.10:/tmp/123"
ssh root@192.168.131.10 "ls /tmp/123/tmp"
scp -r "root@192.168.131.10:/tmp/" "C:\tmp"