Copy-SshId
2.1.1
向目标主机安装SSH公钥实现免密登录,或从目标主机移除本机公钥恢复密码登录。
语法:
安装公钥:Copy-SshId [用户@]主机 [-RemoteUser 用户] [-RemotePort 端口] [-KeyFile 公钥路径]
别名:-RemoteUser=-l -RemotePort=-p -KeyFile=-i
例:Copy-SshId root@192.168.1.10
Copy-SshId 192.168.1.10 -l root -p 2222 -i C:\Users\xxx\.ssh\id_ed25519.pub
未指定 -KeyFile 时自动选用 ~\.ssh 下第一个可用公钥;免密已生效时直接跳过。
移除公钥:Remove-SshId
语法:
安装公钥:Copy-SshId [用户@]主机 [-RemoteUser 用户] [-RemotePort 端口] [-KeyFile 公钥路径]
别名:-RemoteUser=-l -RemotePort=-p -KeyFile=-i
例:Copy-SshId root@192.168.1.10
Copy-SshId 192.168.1.10 -l root -p 2222 -i C:\Users\xxx\.ssh\id_ed25519.pub
未指定 -KeyFile 时自动选用 ~\.ssh 下第一个可用公钥;免密已生效时直接跳过。
移除公钥:Remove-SshId
向目标主机安装SSH公钥实现免密登录,或从目标主机移除本机公钥恢复密码登录。
语法:
安装公钥:Copy-SshId [用户@]主机 [-RemoteUser 用户] [-RemotePort 端口] [-KeyFile 公钥路径]
别名:-RemoteUser=-l -RemotePort=-p -KeyFile=-i
例:Copy-SshId root@192.168.1.10
Copy-SshId 192.168.1.10 -l root -p 2222 -i C:\Users\xxx\.ssh\id_ed25519.pub
未指定 -KeyFile 时自动选用 ~\.ssh 下第一个可用公钥;免密已生效时直接跳过。
移除公钥:Remove-SshId [用户@]主机 [-RemoteUser 用户] [-RemotePort 端口] [-KeyFile 公钥路径]
例:Remove-SshId root@192.168.1.10
仅在当前可免密登录时执行;未指定 -KeyFile 时移除 ~\.ssh 下所有公钥对应条目。
Show more
语法:
安装公钥:Copy-SshId [用户@]主机 [-RemoteUser 用户] [-RemotePort 端口] [-KeyFile 公钥路径]
别名:-RemoteUser=-l -RemotePort=-p -KeyFile=-i
例:Copy-SshId root@192.168.1.10
Copy-SshId 192.168.1.10 -l root -p 2222 -i C:\Users\xxx\.ssh\id_ed25519.pub
未指定 -KeyFile 时自动选用 ~\.ssh 下第一个可用公钥;免密已生效时直接跳过。
移除公钥:Remove-SshId [用户@]主机 [-RemoteUser 用户] [-RemotePort 端口] [-KeyFile 公钥路径]
例:Remove-SshId root@192.168.1.10
仅在当前可免密登录时执行;未指定 -KeyFile 时移除 ~\.ssh 下所有公钥对应条目。
Installation Options
Owners
Copyright
(c) 2026 埃博拉酱. All rights reserved.
Package Details
Author(s)
- 埃博拉酱
Tags
SSH 公钥 免密登录 authorized_keys OpenSSH Windows Linux
Dependencies
This module has no dependencies.
Release Notes
修复Linux上的语法错误问题,绕开 Windows OpenSSH 客户端对 umac 系列 MAC 的计算缺陷
FileList
- Copy-SshId.nuspec
- Copy-SshId.psd1
- Copy-SshId.psm1
- Install-SshKey.ps1
- Install-SshKey.sh
- Invoke-Bootstrap.ps1
- Read-SshPassword.ps1
- Set-DefaultShell.ps1
- Uninstall-SshKey.ps1
- Uninstall-SshKey.sh
Version History
| Version | Downloads | Last updated |
|---|---|---|
| 2.1.1 (current version) | 10 | 9/14/2026 |
| 2.1.0 | 37 | 8/4/2026 |
| 2.0.0 | 41 | 6/30/2026 |