win10下复制ssh公钥到linux

发布时间 2023-04-27 11:07:12作者: 绿豆淀粉好勾芡儿

win10端已经生成了ssh的公钥。
在powershell中使用ssh-copy-id命令,提示如下:

ssh-copy-id: The term 'ssh-copy-id' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

可用如下命令代替

Get-content .\.ssh\id_rsa.pub | ssh {user}@{host} "mkdir -p .ssh && cat >> .ssh/authorized_keys"

说明:
.\.ssh\id_rsa.pub 指ssh公钥的路径
{user}@{host} 替换为自己需要的用户和ip。root用户没有权限问题,其他用户未测试。