ssh 可以设置常用地登录吗?
source link: https://www.v2ex.com/t/778496
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
cherbim 1 天前 via Android
wzhpro 1 天前
chenqh 1 天前
yanqiyu 1 天前
ronman 1 天前
uncat 1 天前
本地维护一份 ~/.ssh/config 配置. 将 git 仓库中的 config 文件软链到 ~/.ssh/config. 然后 config 就可以版本控制了.
然后. 用如下的配置模板为每个项目的服务器添加一份配置.
Host project-1
User <username1>
HostName <IP1>
ProxyJump <username2>@<IP2>
project-1 是一个 nickname.
<username1> 是登陆服务器的地址.
<IP1> 是服务器的 IP.
<username2> 是 ssh 登陆跳转服务器的地址.
<IP2> 是跳转服务器的 IP.
添加了这样的配置后. 登陆服务器. 以往的命令: ssh <username1>@<IP1> 就会变成 ssh project-1. 这里面 <username2>@<IP2> 对应的跳转服务器的作用是: 在你每次 ssh project-1 时, 流量都会先发给 <username2>@<IP2> 对应的跳转服务器, 由跳转服务器发出. 这样, 你所有的 ssh 登陆请求就会有一个固定的来源 IP 了. 这个 IP 就是 IP2(跳转服务器的 IP). 一般云服务商都一提供网络安全组. 将 22 端口设为只允许 IP 登陆即可.
最终你的 git 仓库中的 config 文件会变成下面的形式:
Host project-1
User <username1>
HostName <IP1>
ProxyJump <username2>@<IP2>
Host project-3
User <username3>
HostName <IP3>
ProxyJump <username2>@<IP2>
Host project-4
User <username4>
HostName <IP4>
ProxyJump <username2>@<IP2>
Host project-5
User <username5>
HostName <IP5>
ProxyJump <username2>@<IP2>
# 类似上面的形式. 每次有新的项目. 就添加一个块. 然后推送到远程仓库. 让其他小伙伴拉取这个仓库. 添加软链接到 ~/.ssh/config 即可.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK