레이블이 sshpass인 게시물을 표시합니다. 모든 게시물 표시
레이블이 sshpass인 게시물을 표시합니다. 모든 게시물 표시

ansible ssh password 옵션

# ansible 수행시 target 서버에 커버로스 인증을 사용할 수 없어
# 직접 ssh password(암호)를 명시해야 되는 경우 --ask-pass 옵션을 사용하면
# 암호 입력 프롬프트가 표시해 암호를 입력 할 수 있다.
ansible-playbook -i testserver test.yaml --ask-pass

# 또는 인벤토리 파일에 ansible_password 변수로도 설정할 수 있다.
testserver ansible_host=ysoftman.test.com ansible_password="password123"

# 그런데 위 두방법 모두 다음과 같은 에러가 발생한다.
to use the 'ssh' connection type with passwords, you must install the sshpass program

# ansible 은 ssh 연결로 암호를 묻는 프롬프트가 뜨는데
# sshpass 는 암호 프롬프트 없이 인증 해준다.

# sshpass 설치
# centos 계열
yum install sshpass

# ubuntu 계열
apt-get install sshpass

# mac
brew install hudochenkov/sshpass/sshpass

# 이제 --ask-pass 사용시 최초 한번만 암호를 입력하면 에러 없이 진행된다.
ansible-playbook -i testserver test.yaml --ask-pass
# 또는 암호 프롬프트 없이 사용할 경우
sshpass -p password123 ansible-playbook -i testserver test.yaml --ask-pass

# 참고로 ssh 연결시에 암호 프롬프트 없이 사용하기
sshpass -p password123 ssh ysoftman@ysoftman.test.com