当前位置:网站首页>SaltStack之salt-ssh
SaltStack之salt-ssh
2022-07-28 17:29:00 【阿木690】
文章目录
1. salt-ssh介绍
salt-ssh可以让我们不需要在受控机上安装salt-minion客户端也能够实现管理操作。
1.1 salt-ssh的特点
- 远程系统需要Python支持,除非使用-r选项发送原始ssh命令
- salt-ssh是一个软件包,需安装之后才能使用,命令本身也是salt-ssh
- salt-ssh不会取代标准的Salt通信系统,它只是提供了一个基于SSH的替代方案,不需要ZeroMQ和agent
请注意,由于所有与Salt SSH的通信都是通过SSH执行的,因此它比使用ZeroMQ的标准Salt慢得多
1.2 salt-ssh远程管理的方式
salt-ssh有两种方式实现远程管理,一种是在配置文件中记录所有客户端的信息,诸如 IP 地址、端口号、用户名、密码以及是否支持sudo等;另一种是使用密钥实现远程管理,不需要输入密码。
2. salt-ssh管理
在 master 上安装 salt-ssh
[[email protected] ~]# yum -y install salt-ssh
2.1 通过使用用户名密码的SSH实现远程管理
修改配置文件,添加受控机信息
[[email protected] ~]# vim /etc/salt/roster
....此处省略N行
node1:
host: 192.168.91.134
user: root
passwd: amu123
[[email protected] ~]# salt-ssh 'node1‘ test.ping
node1:
----------
retcode:
10
stderr:
ERROR: Unable to locate appropriate python command
stdout:
ERROR: Python version error. Recommendation(s) follow:
- Install Python 3 on the target machine(s)
- You can use ssh_pre_flight or raw shell (-r) to install Python 3 // 需要安装python3
// 安装python3
[[email protected] ~]# salt-ssh -r 'node1' 'yum -y install python3'
[[email protected] ~]# which python3
/usr/bin/python3
// 安装完之后在测试
[[email protected] ~]# salt-ssh 'node1' test.ping
node1:
True
测试连通性
// 第一次ping的时候他会问你是否要继续连接
[[email protected] .ssh]# ls
known_hosts
[[email protected] .ssh]# ls
known_hosts
[[email protected] .ssh]# rm -f known_hosts
[[email protected] .ssh]# salt-ssh 'node1' test.ping
node1:
----------
retcode:
254
stderr:
stdout:
The host key needs to be accepted, to auto accept run salt-ssh with the -i flag:
The authenticity of host '192.168.91.134 (192.168.91.134)' can't be established.
ECDSA key fingerprint is SHA256:Nz8CAwwL3HRh/Lvqejqa+eiV3A09xGYYfG2A/W8wRPs.
ECDSA key fingerprint is MD5:8c:b3:22:14:7a:8a:bc:34:f9:9d:3c:3a:07:8a:96:20.
Are you sure you want to continue connecting (yes/no)?
从上面的信息可以看出,第一次访问时需要输入 yes/no ,但是 saltstack 是不支持交互式操作的,所以为了解决这个问题,我们需要对其进行设置,让系统不进行主机验证。
[[email protected] .ssh]# vim ~/.ssh/config
StrictHostKeyChecking no
[[email protected] .ssh]# salt-ssh '*' test.ping
node1:
True
2.2 通过salt-ssh初始化系统安装salt-minion
安装 salt-ssh
[[email protected] ~]# yum -y install salt-ssh
修改roster配置文件,添加受控主机
[[email protected] ~]# vim /etc/salt/roster
....此处省略N行
node1:
host: 192.168.91.134
user: root
passwd: amu123
测试连通性
[[email protected] ~]# salt-ssh 'node1' test.ping
node1:
True
执行状态命令,初始化系统,安装salt-minion
[[email protected] ~]# cd /srv/salt/base/init/
[[email protected] init]# ls
basepkgs history postfix sshd yum
chrony kernel salt-minion sudo
firewalld main.sls selinux timeout
// 准备工作
[[email protected] init]# cd salt-minion/
[[email protected] salt-minion]#
[[email protected] salt-minion]# ls
files main.sls
[[email protected] salt-minion]# vim main.sls
include:
- init.yum.main
salt-minion:
pkg.installed
/etc/salt/minion:
file.managed:
- source: salt://init/salt-minion/files/minion.j2
- user: root
- group: root
- mode: '0644'
- template: jinja
- require:
- pkg: salt-minion
salt-minion.service:
service.running:
- enable: true
- reload: true
- watch:
- file: /etc/salt/minion
// 开始安装
[[email protected] ~]# systemctl status salt-minion
Unit salt-minion.service could not be found.
[[email protected] ~]# salt-ssh 'node1' state.sls init.salt-minion.main
// 查看安装情况
[[email protected] yum.repos.d]# systemctl status salt-minion
● salt-minion.service - The Salt Minion
Loaded: loaded (/usr/lib/systemd/system/salt-minion.servi>
Active: active (running) since Mon 2021-11-29 17:19:08 CS>
Docs: man:salt-minion(1)
file:///usr/share/doc/salt/html/contents.html
https://docs.saltproject.io/en/latest/contents.ht>
Main PID: 77393 (salt-minion)
Tasks: 3 (limit: 4743)
Memory: 50.4M
CGroup: /system.slice/salt-minion.service
├─77393 /usr/bin/python3.6 /usr/bin/salt-minion
└─77429 /usr/bin/python3.6 /usr/bin/salt-minion
Nov 29 17:19:07 node1 systemd[1]: Starting The Salt Minion...
Nov 29 17:19:08 node1 systemd[1]: Started The Salt Minion.
// 查看key
[[email protected] ~]# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
node1
Rejected Keys:
// 接受所有key
[[email protected] ~]# salt-key -yA
The following keys are going to be accepted:
Unaccepted Keys:
node1
Key for minion node1 accepted.
[[email protected] ~]# salt-key -L
Accepted Keys:
node1
Denied Keys:
Unaccepted Keys:
Rejected Keys:
// 进行ping通测试
[[email protected] ~]# salt 'node1' test.ping
node1:
True
边栏推荐
- C language (high-level) character function and string function + Exercise
- Gmoea code operation 2 -- establishment and operation of operation environment
- Kali doesn't have an eth0 network card? What if you don't connect to the Internet
- C语言循环语句强化练习题
- 2、 Uni app login function page Jump
- 【雷达】基于核聚类实现雷达信号在线分选附matlab代码
- Bm11 list addition (II)
- SQL审核工具自荐Owls
- Pytorch GPU yolov5 reports an error
- From Bayesian filter to Kalman filter (2)
猜你喜欢

DevCon.exe 导出output至指定文件

【已解决】AC86U ML改版固件虚拟内存创建失败,提示USB磁盘读写速度不满足要求

Photoshop web design practical tutorial

【物理应用】大气吸收损耗附matlab代码

Adobe Flash player 34.0.0.92 and available version modification methods (2021-01-23

Understanding of PID

【图像隐藏】基于DCT、DWT、LHA、LSB的数字图像信息隐藏系统含各类攻击和性能参数附matlab代码
![[image segmentation] vein segmentation based on directional valley detection with matlab code](/img/82/7b7b761c975cd5c2f5b8f3e43592d2.png)
[image segmentation] vein segmentation based on directional valley detection with matlab code

BLDC 6步换相 simulink

BM16 删除有序链表中重复的元素-II
随机推荐
[physical application] atmospheric absorption loss with matlab code
【物理应用】大气吸收损耗附matlab代码
CVPR19 - 调参干货《Bag of Tricks for Image Classification with Convolutional Neural Network》
3、 Uni app fixed or direct to a certain page
ES6 conversion of new data type set and arr set map
BM16 delete duplicate elements in the ordered linked list -ii
From Bayesian filter to Kalman filter (zero)
BLDC 6步换相 simulink
Kotlin Android development novice tutorial
架构实战营第8模块作业
[solved] ac86u ml revision firmware virtual memory creation failed, prompting that the USB disk reading and writing speed does not meet the requirements
Qt: 一个SIGNAL绑定多个SLOT
Lookup - lookup of sequential table and ordered table
用LEX(FLEX)生成PL语言的词法分析器
Fantasy 5 (ue5) game engine complete course 2022
An intern's journey to cnosdb
From Bayesian filter to Kalman filter (2)
Doxygen文档生成工具
The ever-changing pointer ----- C language
About ASM redundancy