给自己做笔记,方便未来查阅
基本原理和相关指令
参考:SSH教程
Windows系统使用ssh-copy-id报错
参考链接:win10 ssh 上传密钥过程,出现 无法将“ssh-copy-id”项识别
打开powershell,将以下内容整体运行即可
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"
}
}



