리눅스
Are you sure you want to continue connecting (yes/no)?
snoopybox
2013. 9. 1. 16:23
리눅스 ssh 연결시 Are you sure you want to continue connecting (yes/no)? 질문 안 나오게 하는 방법
물론 한번 yes 해두면 다음부터는 안 물어보지만, 무조건 yes로 응답하려면 아래와 같이 옵션을 주면 된다.
ssh -o StrictHostKeyChecking=no root@192.168.0.10
이 옵션을 매번 입력하기 귀찮다면 아래와 같이 ssh_config 파일에 넣어주면 된다.
# vi /etc/ssh/ssh_config
StrictHostKeyChecking no
이렇게 하면 yes/no는 물어보지 않지만, 아래와 같이 경고 한 줄은 나온다.
Warning: Permanently added '192.168.0.10' (RSA) to the list of known hosts.
이 경고는 -q 옵션을 붙여주면 나타나지 않는다.
ssh -q -o StrictHostKeyChecking=no root@192.168.0.10
아래는 본인이 회사에서 XenServer 관리 편의를 위해 만들어둔 스크립트 예제이다. 전체 서버 또는 Pool 단위로 접속해서 정보를 긁어오거나 명령어 실행, 파일 배포 등이 필요할 때 활용하고 있다. 아래 예제는 Guest VM에 XenTools가 설치되어 있지 않거나 구 버전인 경우를 찾아 List를 출력하는 것.
# start.sh
# serverlist.txt
# start_expect.sh
# checkXentools.sh
물론 한번 yes 해두면 다음부터는 안 물어보지만, 무조건 yes로 응답하려면 아래와 같이 옵션을 주면 된다.
ssh -o StrictHostKeyChecking=no root@192.168.0.10
이 옵션을 매번 입력하기 귀찮다면 아래와 같이 ssh_config 파일에 넣어주면 된다.
# vi /etc/ssh/ssh_config
StrictHostKeyChecking no
이렇게 하면 yes/no는 물어보지 않지만, 아래와 같이 경고 한 줄은 나온다.
Warning: Permanently added '192.168.0.10' (RSA) to the list of known hosts.
이 경고는 -q 옵션을 붙여주면 나타나지 않는다.
ssh -q -o StrictHostKeyChecking=no root@192.168.0.10
아래는 본인이 회사에서 XenServer 관리 편의를 위해 만들어둔 스크립트 예제이다. 전체 서버 또는 Pool 단위로 접속해서 정보를 긁어오거나 명령어 실행, 파일 배포 등이 필요할 때 활용하고 있다. 아래 예제는 Guest VM에 XenTools가 설치되어 있지 않거나 구 버전인 경우를 찾아 List를 출력하는 것.
# start.sh
#! /bin/bash while read -a arr do ./start_expect.sh ${arr[0]} ${arr[1]} done < serverlist.txt
# serverlist.txt
192.168.0.10 Password 192.168.0.11 Password 192.168.0.12 Password 192.168.0.13 Password 192.168.0.14 Password
# start_expect.sh
#!/usr/bin/expect set timeout 20 set ipaddr [lindex $argv 0] set pass [lindex $argv 1] set file checkXentools.sh spawn -noecho scp -o StrictHostKeyChecking=no -q $file root@$ipaddr:/root/$file expect "password:" send "$pass\r" expect eof spawn -noecho ssh -o StrictHostKeyChecking=no -q root@$ipaddr "sh /root/$file" expect "password:" send "$pass\r" expect eof
# checkXentools.sh
#!/bin/bash IFS=, for uuid in `xe vm-list is-control-domain=false --minimal` do vm=`xe vm-param-get uuid=$uuid param-name=name-label` xentool=`xe vm-param-get uuid=$uuid param-name=PV-drivers-up-to-date` if ! [ "$xentool" = "true" ] then echo -e "$vm\\t$xentool" fi done