首页 > 其他分享 >ssh免密登录

ssh免密登录

时间:2022-12-20 22:44:28浏览次数:60  
标签:Defiler 免密 登录 rsa publicKey ssh copy id

转载自链接:https://blog.csdn.net/Defiler_Lee/article/details/116278442
配置过程

  1. 首先生成密钥对

ssh-keygen -t rsa #-t表示类型选项,这里采用rsa加密算法
2. 上传公钥
ssh-copy-id [email protected]

遇到问题
在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

标签:Defiler,免密,登录,rsa,publicKey,ssh,copy,id
From: https://www.cnblogs.com/Guang-Jun/p/16995279.html

相关文章