300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > ssh配置config文件 实现vscode免密登陆

ssh配置config文件 实现vscode免密登陆

时间:2023-05-14 07:52:04

相关推荐

ssh配置config文件 实现vscode免密登陆

在使用ssh连接服务器时,每一次用vscode连接服务器进行开发,都需要输入密码,相当鸡肋,对config的配置能够实现解决这个问题。

step1:生成ssh密钥:(如果已经有了就不需要了)

# 使用以下命令 一路回车即可ssh-keygen -t rsa# 为.ssh目录设置权限chmod 600 ~/.ssh/config

step2: config文件配置十分简单,只需要按照以下格式配置即可。

Host 192.168.xxx.64HostName 192.168.xxx.64User admin#Host 为了便于区分同一主机的不同Port,可以修改为不同的名字。#比如下边的*.physical是物理机IP,*.container是运行在该物理机上的一个container,用的是物理机的端口2222Host 231.180.containerHostName 192.168.xxx.180Port 2222User rootHost 231.180.physicalHostName 192.168.xxx.180User yourusername

step3:实现免密登陆

# 将密钥copy到work1,需要输入work1的登陆密码(此登陆密码为config重配置的user密码)ssh-copy-id 231.180.physical# 成功后会有如下提示Now try logging into the machine, with: "231.180.physical'"and check to make sure that only the key(s) you wanted were added.#现在使用如下即可登陆231.180.physical(其他主机方法一样)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。