提示:解决Vscode每次连接ssh登入需要输入密码问题(免密登入)
问题
可以看到每次登入,或者切换的时候都需要输入密码,很麻烦,我有强迫症。
一、解决方案
1检查windows中是否安装ssh:
二、使用步骤
1.win10操作
2.生成id_rsa.pub(用github时生成过,这步忽略)
cmd 输入ssh-keygen
其他地方都是回车,
PS C:\Users\Christopher> ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Christopher/.ssh/id_rsa):
Created directory 'C:\Users\Christopher/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\Christopher/.ssh/id_rsa.
Your public key has been saved in C:\Users\Christopher/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:/mjkrJOQbRzCAwlSPYVBNcuxntm/Ms5/MMC15dCRrMc christopher@Christopher-Win10-VM-01
The key's randomart image is:
+---[RSA 2048]----+
|oo.+o== o.o |
|. o +. = o = |
| o .+. . B |
| +..+o o E |
| *+.S. . |
| o +...o |
| o =. .o |
| o.*o .. |
| .=+++. |
+----[SHA256]-----+
PS C:\Users\Christopher>
3.xshell链接后创建目录
mkdir .ssh
将C://Users/xxx/.ssh/id_rsa.pub拷贝到服务器的.ssh/authorized_keys,请不要采用复制粘贴文本的方式,我是用xftp将文件复制到服务器,再执行如下命令:
复制如下
4.然后xshell输入
chmod 700 .ssh
cd .ssh
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
sshd restart
5.打开vscode
添加扩展
打开远程
如下
如下
配置文件里面配置
Host CTF
HostName 172.19.12.206
Port 22
User root
重新打开Vscode就免登入了。
参考文献
https://blog.csdn.net/qq_41381865/article/details/116120074
https://www.cnblogs.com/dev-sy/p/12893012.html
https://blog.csdn.net/weixin_42397613/article/details/114983147
https://www.jianshu.com/p/cc1f599c8841
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)