配置过程
1. 首先生成密钥对
ssh-keygen -t rsa #-t表示类型选项,这里采用rsa加密算法
2. 上传公钥
ssh-copy-id ldz@192.168.0.1
遇到问题
在windows10上配置时,会遇到如下错误:
ssh-copy-id : 无法将“ssh-copy-id”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。
解决方案是在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"
}
}