운영 방법|SSH 자동화 클 러 스 터 관리,자동화 스 크 립 트 관리
15190 단어 자동화 운영
호스트
IP
호스트 관리
192.168.182.10
호스트 관리-1
192.168.182.11
호스트 관리-2
192.168.182.12
2.SSH 클 러 스 터 관리
1.ssh 명령 을 사용 하여 관리 되 는 호스트 의 현재 시간 조회
[root@localhost ~]# ssh -l root 192.168.182.11 date
root@192.168.182.11's password:
2020 02 05 19:19:01 CST
[root@localhost ~]# ssh -l root 192.168.182.12 date
root@192.168.182.12's password:
2020 02 05 19:19:07 CST
2.키 생 성
ssh-keygen
,비밀 로그 인 면제ssh-keygen
[root@localhost ~]# ssh-keygen ///
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:2oL59QLNUNyK/ylwHD0nvd5/YcJZH0PiXknnJqDm6IE root@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
| . . |
| o . .. o.|
| o o o..+.o|
| o o * o..*o|
| BS= +o.+o+|
| oEoO . .= o.|
| o o=oo o .o .|
| . o+.o . . .|
| . o. .o|
+----[SHA256]-----+
[root@localhost ~]# cd /root/.ssh/
[root@localhost .ssh]# ls
id_rsa( ) id_rsa.pub( ) known_hosts
[root@localhost .ssh]# for i in {0,1,2}; do ssh-copy-id -i 192.168.1.1$i ; done
[root@test .ssh]# pwd
/root/.ssh
[root@test .ssh]# ls
authorized_keys( )
[root@localhost ~]# ssh -l root 192.168.182.10 date
2020 02 05 19:39:33 CST
[root@localhost ~]# ssh -l root 192.168.182.11 date
2020 02 05 19:39:37 CST
[root@localhost ~]# ssh -l root 192.168.182.12 date
2020 02 05 19:39:43 CST
3.ssh 스 크 립 트 클 러 스 터 관리 사용
[root@localhost ~]# cat ip_list.txt
192.168.182.10
192.168.182.11
192.168.182.12
[root@localhost ~]# vim auto_for_ssh.sh
#!/bin/bash
#auto remote exec command
############################
IP_FILES="/root/ip_list.txt" ///
COMMAND="$*" ///
for IP in `cat $IP_FILES` /// IP
do
echo -e "\033[32mThe $IP remote command follow results:\033[0m" ///
ssh -l root $IP "$COMMAND" ///ssh
echo ///
done
[root@localhost ~]# sh auto_for_ssh.sh date
The 192.168.182.10 remote command follow results:
2020 02 05 19:53:18 CST
The 192.168.182.11 remote command follow results:
2020 02 05 19:53:18 CST
The 192.168.182.12 remote command follow results:
2020 02 05 19:53:19 CST
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
puppet 자동화 운영 의 puppet 자원 기초 지식첫 번 째 줄 의 file 은 자원 의 유형 을 지정 하 는 것 입 니 다. title 의 역할 은 puppet 가 이 자원 을 유일 하 게 표시 할 수 있 도록 하 는 것 입 니 다. 자원 의 title 은 ssh...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.