当前位置:网站首页>Salt SSH of saltstack
Salt SSH of saltstack
2022-07-28 19:31:00 【Amu 690】
List of articles
1. salt-ssh Introduce
salt-ssh So we don't need to install... On the controlled machine salt-minion The client can also implement management operations .
1.1 salt-ssh Characteristics
- The remote system requires Python Support , Unless used -r Option to send the original message ssh command
- salt-ssh It's a software package , It can only be used after installation , The command itself is salt-ssh
- salt-ssh Will not replace the standard Salt communication system , It just provides a platform based on SSH alternatives , Unwanted ZeroMQ and agent
Please note that , Due to all and Salt SSH All communications are through SSH Executive , So it's better than using ZeroMQ Standards for Salt Much slower
1.2 salt-ssh The way of remote management
salt-ssh There are two ways to achieve remote management , One is to record the information of all clients in the configuration file , Such as IP Address 、 Port number 、 user name 、 Password and support sudo etc. ; The other is to use key to realize remote management , No password required .
2. salt-ssh management
stay master Installation on salt-ssh
[[email protected] ~]# yum -y install salt-ssh
2.1 By using the user name and password SSH Realize remote management
Modify the configuration file , Add controlled machine information
[[email protected] ~]# vim /etc/salt/roster
.... Omit here N That's ok
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 // Need to install python3
// install python3
[[email protected] ~]# salt-ssh -r 'node1' 'yum -y install python3'
[[email protected] ~]# which python3
/usr/bin/python3
// Test after installation
[[email protected] ~]# salt-ssh 'node1' test.ping
node1:
True
Test connectivity
// for the first time ping He will ask you if you want to continue connecting
[[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)?
As can be seen from the above information , For the first visit, you need to enter yes/no , however saltstack Interactive operation is not supported , So in order to solve this problem , We need to set it up , Let the system not perform host Authentication .
[[email protected] .ssh]# vim ~/.ssh/config
StrictHostKeyChecking no
[[email protected] .ssh]# salt-ssh '*' test.ping
node1:
True
2.2 adopt salt-ssh Initialize system installation salt-minion
install salt-ssh
[[email protected] ~]# yum -y install salt-ssh
modify roster The configuration file , Add controlled host
[[email protected] ~]# vim /etc/salt/roster
.... Omit here N That's ok
node1:
host: 192.168.91.134
user: root
passwd: amu123
Test connectivity
[[email protected] ~]# salt-ssh 'node1' test.ping
node1:
True
Execute status command , Initialize system , install 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
// preparation
[[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
// Start installation
[[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
// Check the installation
[[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.
// see key
[[email protected] ~]# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
node1
Rejected Keys:
// Accept all 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:
// Conduct ping Pass test
[[email protected] ~]# salt 'node1' test.ping
node1:
True
边栏推荐
- Smart contract security - overflow vulnerability
- 使用SaltStack自动化部署LNMP
- BLDC 6步换相 simulink
- 宝塔面板搭建小说CMS管理系统源码实测 - ThinkPHP6.0
- BLDC 6-step commutation simulink
- Nips18 (AD) - unsupervised anomaly detection using geometric transformations using geometric augmentation
- 机器学习 --- 模型评估、选择与验证
- 搜索问题与技术
- lua语言的左对齐函数(手写)
- 我的第二次博客——C语言
猜你喜欢

Pytorch:快速求得NxN矩阵的主对角线(diagonal)元素与非对角线元素

SQL audit tool self introduction owls

英文翻译意大利语-批量英文翻译意大利语工具免费

ES6 conversion of new data type set and arr set map

英文翻译葡萄牙语-批量英文转换葡萄牙语-各种语言免费互译转换

navicate修改数据库名的方式

Application of time series database in museum environment detection

Asp net MVC web development tutorial

剑指 Offer II 109. 开密码锁

WPF 实现带蒙版的 MessageBox 消息提示框
随机推荐
SaltStack之return与job管理
After reading the thesis for three years, I learned to read the abstract today
中国首枚芯片邮票面世:内置120um超薄NFC芯片
navicate修改数据库名的方式
App自动化测试是怎么实现H5测试的
Mid 2022 summary
Pytorch:快速求得NxN矩阵的主对角线(diagonal)元素与非对角线元素
Quickly install torch spark, torch geometric and other packages in moment pool cloud
为研发高端光刻胶,晶瑞股份斥资7500万元购买SK海力士的ASML光刻机
Cvpr21 unsupervised anomaly detection cutpaste:self supervised learning for anomaly detection and localization
Nips18(AD) - 利用几何增广的无监督异常检测《Deep Anomaly Detection Using Geometric Transformations》
Jestson nano Object detection
Libgdx learning road 02: draw game map with tiled
ES6 conversion of new data type set and arr set map
Pytoch: quickly find the main diagonal elements and non diagonal elements of NxN matrix
以数字化转型为契机,3C企业如何通过SRM供应商云协同平台实现高效协同?
智能合约安全——溢出漏洞
SaltStack常用的模块
WPF implements MessageBox message prompt box with mask
Application of time series database in monitoring operation and maintenance platform