如何使用VScode使用ssh连接远程服务器不需要输入密码直接登录

发布于:2025-07-17 ⋅ 阅读:(24) ⋅ 点赞:(0)
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 yes
   PasswordAuthentication yes
#   HostbasedAuthentication no

在这里插入图片描述
右键点击id_rsa然后下载到本地的用户文件夹下,如果你有多个服务器连接的需求,需要建立多个文件夹来保存id_rsa文件

然后设置文件,增加一行

在这里插入图片描述

参考
如何使用VScode使用ssh连接远程服务器不需要输入密码直接登录


网站公告

今日签到

点亮在社区的每一天
去签到