여러 ssh 호스트에 대한 인증 키 업로드를 자동화하고 있으므로 스크립트를 실행할 때마다 authorized_keys에 키를 추가하지 않으려합니다. 따라서 ssh가 키를 업로드하기 전에 키 인증에 연결할 수 있는지 확인합니다.ssh가 내 bash 스크립트를 중단하는 이유는 무엇입니까?
문제는 스크립트는 사용자가 이미 키를 가지고 상기 제 서버의 루프를 중지한다는 것이다
스크립트는 bash/ssh test for public key authentication
while read SERVER; do
CONN="[email protected]$SERVER"
echo "$CONN: "
ssh -q -o "BatchMode yes" $CONN 'true'
RC=$?
if [[ $RC -ne 0 ]]
then
echo "key auth did not succeed, trying to uploading key:"
../ssh-uploadkeys/ssh-uploadkeys $CONN
else
echo "key auth ok, no need to upload key"
fi
done < servers.txt
이 출력으로부터 통보에 기초하여 키의 인증을 시도한다.
[email protected]:
key auth ok, no need to upload key
하여 Servers.txt :
the.host.com
another.host.com
the.ghost.com
내 스크립트 테로 Karvinen에 의해 작성되어 사용하는 SSH-uploadkeys 스크립트 http://terokarvinen.com/ssh-uploadkeys.html
효과가있었습니다. 감사! –