[vscode]远程ssh用isa登录免密码

Abestract: 避免每次用vscode远程ssh登录都要输入密码。

首要的:分为本机,与远程主机

1.在本机上创建密钥

ssh-keygen -t ed25519

然后会有输出

Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\uid03619/.ssh/id_ed25519): esc_net
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in esc_net
Your public key has been saved in esc_net.pub
The key fingerprint is:

在这一段中,会有三个冒号后面需要输入的内容,只在第一个冒号后加了内容esc_net,这会生成对应的密钥文件的名字在路径C:\Users\uid03619\下。

假设有多台本机要连接远程主机,一定要设置一下passphrase,避免用户名重名。

2.在远程主机上编辑密钥授权

vim ~/.ssh/authorized_keys

在本机上打开刚刚生成的文件:C:\Users\uid03619/.ssh/esc_net.pub 复制其中的内容:ssh-ed25519 ........ 到远程主机的~/.ssh/authorized_keys

3.修改本机上的config文件

文件位于:C:\Users\uid03619/.ssh/condig 添加以下内容:

  Host xx.xx.xx.xx
    HostName xx.xx.xx.xx
    User root
    ForwardAgent yes
    IdentityFile ~/.ssh/esc_net

Last modified on 2025-12-29