- 首先在windows电脑上生存私秘钥对
ssh-keygen -t ed25519 -b 4096
- 然后在powershell下执行如下命令
$USER_AT_HOST="your-user-name-on-host@hostname" $PUBKEYPATH="$HOME\.ssh\id_ed25519.pub" $pubKey=(Get-Content "$PUBKEYPATH" | Out-String); ssh "$USER_AT_HOST" "mkdir -p ~/.ssh && chmod 700 ~/.ssh && echo '${pubKey}' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys" - 最后在vscode的remote-ssh插件中增加
IdentityFile配置
Host name-of-ssh-host-here
User your-user-name-on-host
HostName host-fqdn-or-ip-goes-here
IdentityFile ~/.ssh/id_ed25519-remote-ssh