ssh免密登录
转载自链接:https://blog.csdn.net/Defiler_Lee/article/details/116278442
配置过程
- 自己电脑本地首先生成密钥对
ssh-keygen -t rsa
#-t表示类型选项,这里采用rsa加密算法
2. 本地上传公钥到服务器
ssh-copy-id [用户名]@[ip地址]
遇到问题
在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"
}
}
转载自链接:https://blog.csdn.net/Defiler_Lee/article/details/116278442