在 Mac 电脑中 ssh 读取加载 config.d 目录

栏目: 服务器 · 发布时间: 7年前

内容简介:一般情况下,我们ssh 配置都是使用但是如果我们线上所要维护或者要连接的机器比较多,我们怎么分门别类呢?大家请看:

背景

一般情况下,我们ssh 配置都是使用 ~/.ssh/config 里面的配置即可。

但是如果我们线上所要维护或者要连接的机器比较多,我们怎么分门别类呢?

大家请看:

Include
	Include the specified configuration file(s).  Multiple path‐names may be specified and each pathname may contain glob(3) wildcards and, for user configurations, shell-like ‘~’ references to user home directories.  Files without absolute paths are assumed to be in ~/.ssh if included in a user configuration file or /etc/ssh if included from the system configuration file. Include directive may appear inside a Match or Host block to perform conditional inclusion.

注意: Include 必须在 config 配置的 Host 之前的位置,不能夹杂在多个 Host 之间。

涉及到的脚本:

Makefile

install-ssh-config:
	@./install-ssh-config.sh $(identify_file)

install-ssh-config.sh:

identify_file=${1:-""}
if [ ! -z $identify_file ]; then
	identify_file="IdentityFile $identify_file"
fi

...
grep -q -F 'Include ~/.ssh/config.d/*' "$HOME/.ssh/config" || cat -n "$HOME/.ssh/config" |grep -i host |awk '{print $1-1}'|sed -n "1"p |xargs -I LINE sed -i '' -e $'LINE i\\\n''Include ~/.ssh/config.d/*' "$HOME/.ssh/config"

分步分析:

$参数位置
sed -i '' -e $'LINE i\\\n''xxx'

参考资料

  1. What’s wrong with my OpenSSH Include directive?
  2. ssh_config — OpenSSH SSH client configuration files

茶歇驿站

一个可以让你停下来看一看,在茶歇之余给你帮助的小站,这里的内容主要是后端技术,个人管理,团队管理,以及其他个人杂想。

在 Mac 电脑中 ssh 读取加载 config.d 目录


以上所述就是小编给大家介绍的《在 Mac 电脑中 ssh 读取加载 config.d 目录》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

集体智慧编程

集体智慧编程

TOBY SEGARAN / 莫映、王开福 / 电子工业出版社 / 2009-1 / 59.80元

本书以机器学习与计算统计为主题背景,专门讲述如何挖掘和分析Web上的数据和资源,如何分析用户体验、市场营销、个人品味等诸多信息,并得出有用的结论,通过复杂的算法来从Web网站获取、收集并分析用户的数据和反馈信息,以便创造新的用户价值和商业价值。全书内容翔实,包括协作过滤技术(实现关联产品推荐功能)、集群数据分析(在大规模数据集中发掘相似的数据子集)、搜索引擎核心技术(爬虫、索引、查询引擎、Page......一起来看看 《集体智慧编程》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具