아래는 스크립트입니다.
여러 서버에 로그인하고 커널 버전을 확인하고 싶었습니다.
#!/bin/bash
#input server names line by line in server.txt
cat server.txt | while read line
do
sshpass -p password ssh root@$line << EOF
hostname
uname -r
EOF
done
나는 다음과 같은 출력을 기대할 것이다.
server1_hostname
kernel_version
server2_hostname
kernel_version
등등..
server.txt에서 약 80 대의 서버로이 스크립트를 실행했습니다.
그리고 내가 얻은 결과는 .....
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
========================================================================
================================ WARNING ===============================
========================================================================
This system is solely for the use of authorized personnel. Individuals
using this system are subject to having some or all of their activities
monitored and recorded. Anyone using this system expressly consents to
such monitoring and is advised that any unauthorized or improper use of
this system may result in disciplinary action up to and including
termination of employment. Violators may also be subject to civil and/or
criminal penalties.
========================================================================
Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
xxxxdev01
2.6.32-431.23.3.el6.x86_64
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
여기서는 1 개의 호스트에 대해서만 출력을 xxxxdev01
받았으며 ssh 배너 및 기타 경고와 함께 제공됩니다.
ssh banner없이 다른 모든 호스트의 출력이 필요합니다. 여기서 무엇이 잘못 되었습니까?
ssh -t -t root@
의사 터미널을 강제 실행 하려면 ...을 사용하십시오 .
sshpass -p password root@server histname
?