vscode插件remote-ssh免密码登录、证书登录、密钥登录、公钥登录Linux服务器。(搭建esp-idf环境免密登录)
·
生成 SSH 公钥
1、通过命令 ssh-keygen 生成 SSH Key:
ssh-keygen -t ed25519 -C eap@gitee.com
-t key 类型
-C 注释(C大写)
PS C:\Windows\System32> ssh-keygen -t ed25519 -C eap@gitee.com
Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\23731/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\23731/.ssh/id_ed25519
Your public key has been saved in C:\Users\23731/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:V3h60I/rwqa08jO1pxSFjc0f1YWRg5Z6wXX9/XWynu8 eap@gitee.com
The key's randomart image is:
+--[ED25519 256]--+
| . +o+B|
| O* +oo|
| =oO...o|
| .*.+..=|
| S +.o oo+|
| ..o .. .|
| .o.... . |
| ..oo=.. o |
| o+=.+. oE|
+----[SHA256]-----+
PS C:\Windows\System32>
找到公钥打开复制


在Ubuntu内粘贴公钥

user@user-virtual-machine:~$ ls -al
total 108
drwxr-xr-x 20 user user 4096 3月 24 10:32 .
drwxr-xr-x 3 root root 4096 3月 4 16:00 ..
-rw------- 1 user user 3328 3月 18 11:43 .bash_history
-rw-r--r-- 1 user user 220 3月 4 16:00 .bash_logout
-rw-r--r-- 1 user user 3799 3月 9 11:15 .bashrc
drwx------ 15 user user 4096 3月 24 15:55 .cache
drwx------ 11 user user 4096 3月 16 10:21 .config
drwxr-xr-x 2 user user 4096 3月 4 16:35 Desktop
drwxr-xr-x 2 user user 4096 3月 4 16:35 Documents
drwxrwxr-x 3 user user 4096 3月 23 16:57 .dotnet
drwxr-xr-x 2 user user 4096 3月 4 16:35 Downloads
drwxrwxr-x 8 user user 4096 3月 13 16:41 esp
drwxrwxr-x 5 user user 4096 3月 7 17:27 .espressif
-rw-rw-r-- 1 user user 122 3月 6 09:51 .gitconfig
drwx------ 3 user user 4096 3月 4 18:01 .gnupg
drwxr-xr-x 3 user user 4096 3月 4 16:35 .local
drwxr-xr-x 2 user user 4096 3月 4 16:35 Music
drwxr-xr-x 2 user user 4096 3月 4 16:35 Pictures
-rw-r--r-- 1 user user 807 3月 4 16:00 .profile
drwxr-xr-x 2 user user 4096 3月 4 16:35 Public
drwx------ 3 user user 4096 3月 7 17:31 snap
drwx------ 2 user user 4096 3月 4 18:01 .ssh
-rw-r--r-- 1 user user 0 3月 5 11:49 .sudo_as_admin_successful
drwxr-xr-x 2 user user 4096 3月 4 16:35 Templates
drwxr-xr-x 2 user user 4096 3月 4 16:35 Videos
drwxr-x--- 5 user user 4096 3月 24 16:24 .vscode-server
-rw-rw-r-- 1 user user 183 3月 23 16:57 .wget-hsts
-rw------- 1 user user 66 3月 24 10:32 .Xauthority
user@user-virtual-machine:~$ cd .ssh/
user@user-virtual-machine:~/.ssh$ ls
user@user-virtual-machine:~/.ssh$ touch ~/.ssh/authorized_keys
user@user-virtual-machine:~/.ssh$ ls
authorized_keys
user@user-virtual-machine:~/.ssh$ chmod 600 ~/.ssh/authorized_keys
user@user-virtual-machine:~/.ssh$ vim authorized_keys
vim打开文件,如果没有vim,下载vim。
不习惯vim可直接用vscode远程打开,粘贴公钥。
vim基本命令:强制退出当前文件
按下 Esc 键,确保处于普通模式。
输入以下命令并按回车: :q! 作用:忽略所有未保存的修改,直接退出当前文件。:wq 作用保存退出。
最后重新打开vscode验证免密登录服务器
更多推荐


所有评论(0)