windows无法使用ssh-copy-id
的解决办法
[toc]
1. 在powershell中执行脚本
在powershell下执行如下脚本就可以了
{IP-ADDRESS-OR-FQDN}写ip地址或者域名或者用户@ip地址或域名
type $env:USERPROFILE\.ssh\id_rsa.pub | ssh {IP-ADDRESS-OR-FQDN} "cat >> .ssh/authorized_keys"
然后输入密码
2. powershell下执行脚本 。
在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"
}
}
然后就可以使用ssh-copy-id了。
输入密码就可以了。
3. 自己复制文件到linux地址上。
https://www.jianshu.com/p/06f3b2d1ebdc
本文转自 https://blog.csdn.net/qq_45624685/article/details/122631083,如有侵权,请联系删除。
评论区