如何使用VScode使用ssh连接远程服务器不需要输入密码直接登录
ssh-keygen
之后一直默认 回车 确认即可结果
(base) amax@amax:/data/std$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/amax/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/amax/.ssh/id_rsa
Your public key has been saved in /home/amax/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:hUNDPp3lUa6whY9SuhEw7pOJEN+kVLFqn0GcU08w34Q amax@amax
The key's randomart image is:
+---[RSA 3072]----+
| . ..*oB...+.. |
| + * O OEB o |
| . o O * X + . |
| . = + B * . |
| + * S o o |
| . . + + |
| o . |
| |
| |
+----[SHA256]-----+
cd ~/.ssh/
结果
(base) amax@amax:/data/std$ cd ~/.ssh/
(base) amax@amax:~/.ssh$ ls
id_rsa id_rsa.pub known_hosts known_hosts.old
cat id_rsa.pub >> authorized_keys
结果
(base) amax@amax:~/.ssh$ cat id_rsa.pub >> authorized_keys
(base) amax@amax:~/.ssh$ ls
authorized_keys id_rsa id_rsa.pub known_hosts known_hosts.old
(base) amax@amax:~/.ssh$
sudo vim /etc/ssh/ssh_config
把 PasswordAuthentication yes 启动
结果
Host *
# ForwardAgent no
# ForwardX11 no
# ForwardX11Trusted yesPasswordAuthentication yes
# HostbasedAuthentication no
右键点击id_rsa然后下载到本地的用户文件夹下,如果你有多个服务器连接的需求,需要建立多个文件夹来保存id_rsa文件
然后设置文件,增加一行
参考
如何使用VScode使用ssh连接远程服务器不需要输入密码直接登录