免密登录
打开powershell
输入ssh-keygen
,一路回车
公钥默认保存再在C:\Users\Administrator/.ssh/id_rsa
然后再输入以下
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"
}
}
就像这样
最后输入 ssh-copy-id root@192.168.0.119
即可
如果有时候连不上
powershell输入以下,然后重连即可
ssh-keygen -f "C:\\Users\\Administrator/.ssh/known_hosts" -R "192.168.12.14"