gpt4 book ai didi

windows - Windows 上的 ssh-copy-id 不起作用 : No such file or directory

转载 作者:行者123 更新时间:2023-12-02 19:53:32 28 4
gpt4 key购买 nike

我想将公钥从 Windows 系统复制到我的服务器。我遇到的问题是,我没有找到 key 的路径。我试过类似的东西:

ssh-copy-id -i C:/Users/username/.ssh/mykey.pub user@serverIP

ssh-copy-id -i ~/.ssh/mykey.pub user@serverIP

结果总是

No such file or directory

我做错了什么?我在 Windows 10

上使用 Git Bash

最佳答案

Git的ssh是OpenSSH的一个版本.您可以通过在 path\to\git\usr\bin 下运行 ssh -V 来确认它。这是它在我的机器上评估的内容:

OpenSSH_7.7p1, OpenSSL 1.0.2o  27 Mar 2018

ssh-copy-id 脚本在内部执行一些 *nix shell 命令(如 execcat 等。您可以通过以下方式找到更多信息以文本模式打开 path\to\git\usr\bin 下的文件),因此它仅适用于 *nix 机器。这就是为什么 path\to\git\usr\bin 下的 ssh-copy-id 不是可执行文件的原因。

根据 this issuePowerShell/Win32-OpenSSH , Windows 不支持 ssh-copy-id

但是,有一些替代方法可以做同样的事情:

this answer 的 powershell 版本可以

Get-Content $env:USERPROFILE\.ssh\id_rsa.pub | ssh <user>@<hostname> "cat >> .ssh/authorized_keys"

还有一个 python 脚本可以做同样的事情:ssh-copy-id for Windows .

关于windows - Windows 上的 ssh-copy-id 不起作用 : No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57629166/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com