1.windows (win+R) 輸入
cmd
2.輸入命令
ssh-keygen
3.ssh-keygen 建立全部 enter 跳過
ssh-copy-id -i ~/.ssh/id_rsa.pub username@hostip -p (port)
5.finish
若出現 無法辨識 'ssh-copy-id' 詞彙是否為 Cmdlet、函數、
將以下粘貼到 powershell enter執行即可
function ssh-copy-id([string]$userAtMachine, $args){
$publicKey = "$ENV:USERPROFILE" + "/.ssh/id_rsa.pub"
if (!(Test-Path "$publicKey")){
Write-Error "ERROR: failed to open ID file '$publicKey': No such file"
}
else {
& cat "$publicKey" | ssh $args $userAtMachine "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1"
}
}