VSCode使用ssh远程连接阿里云

1. 终端选择

Windows使用PowerShell

Ubuntu和Mac使用Terminal

2. 设置ssh

2.1. 第一台电脑

生成密钥

ssh-keygen -o -t rsa -b 4096 -C "email@example.com"

按三次回车

查看密钥

cat ~/.ssh/id_rsa.pub

拷贝密钥,粘贴到服务器的密钥框中

2.2. 第n台电脑

因为阿里云只支持一个ssh公钥,如果想要多个电脑都能连接阿里云,则需保持多台电脑的ssh配置一致

把第一台电脑上打包.ssh文件夹拷贝到第n台电脑。

3. 连接方法

3.1. 测试本地ssh访问

阿里云会提供连接命令

3.2. VSCode访问

也可以把它写到.ssh/config中

Host alphaHostName 6.131.185.72User rootPort 1812

打开VSCode

安装Remote-SSH,Romote Explorer

使用Remote-SSH连接