vscode远程连接linux免密配置

42 阅读1分钟
  1. 首先在windows电脑上生存私秘钥对

ssh-keygen -t ed25519 -b 4096

  1. 然后在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"
    
  2. 最后在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