SSH基础配置
填入地址,回车
bash
ssh user@host-or-ip
然后选择默认的配置,回车,得到以下结果:
-
点击链接
-
选择远程的系统
-
输入密码
免密登录
- 生成SSH密钥:
首先,确保你已经在本地生成了SSH密钥。你可以使用以下命令生成SSH密钥:
csharp
(base) ubuntu@ubuntu-3090x2:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa):
/home/ubuntu/.ssh/id_rsa already exists.
Overwrite (y/n)? n
csharp
(base) ubuntu@ubuntu-3090x2:~$ cd /home/ubuntu/.ssh
(base) ubuntu@ubuntu-3090x2:~/.ssh$ ls
authorized_keys id_rsa id_rsa.pub known_hosts
- 创建authorized_keys文件:
csharp
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
- 将SSH私钥下载到本地并添加到VSCODEconfig:
csharp
Host ************
HostName ************
User ubuntu
IdentityFile "C:\Users\using\Documents\remote\id_rsa"
经过以上操作即可免密登录了。