目录
一、下载Remote-SSH并配置SSH信息
首先在Extension里面搜索Remote-SSH下载:

然后点击左下角绿色按钮进行SSH配置:

选择Open Configuration File。然后选择本机用户的ssh配置文件进行配置:

在配置文件最后面追加以下内容:
Host 服务器IP地址
HostName 服务器IP地址
User 用户名
port 22
二、生成SSH的key并放置远程服务器上
1、首先生成ssh的key,这个教程有很多,例如:
RSA SSH keys
If you use RSA keys for SSH, the US National Institute of Standards and Technology recommends that you use a key size of at least 2048 bits. By default, the ssh-keygen command creates an 1024-bit RSA key.
You can create and configure an RSA key with the following command, substituting if desired for the minimum recommended key size of 2048:
ssh-keygen -t rsa -b 2048 -C "email@example.com"
The -C flag, with a quoted comment such as an email address, is an optional way to label your SSH keys.
You’ll see a response similar to:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
2、将生成的ssh key放置远程服务器,使用以下命令:
ssh-copy-id your-user-name-on-host@host-fqdn-or-ip-goes-here
for example: ssh-copy-id root@172.0.0.1

本文详细介绍了如何在VSCode中配置Remote-SSH插件,包括下载与安装Remote-SSH,配置SSH信息,生成SSH密钥以及将密钥放置到远程服务器上的步骤。适合需要远程连接服务器进行代码编辑的开发者。
1万+





