0
SSH keys when using the Docker executor에있는 gitlab의 설명서에 따라 예상대로 작동하는 원격 서버에 대한 연결을 설정했습니다.Gitlab CI - Bash에서 SSH 키 설정
before_script:
- which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
그러나,이 같은 별도의 스크립트에서 해당 명령을 넣어 싶습니다
before_script:
- bash ./scripts/ssh-config.sh
ssh-config.sh
#!/bin/bash
which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)
eval $(ssh-agent -s)
ssh-add <(echo $SSH_PRIVATE_KEY)
mkdir -p ~/.ssh
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
원격 연결을 시도 서버에서 다음 오류를 제공합니다.
$ bash scripts/ssh-config.sh
/usr/bin/ssh-agent
Agent pid 15
Identity added: /dev/fd/63 (/dev/fd/63)
$ ssh [email protected] "touch test"
Warning: Permanently added 'example.com' (ECDSA) to the list of known hosts.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
스크립트가 올바르게 실행 된 것으로 보였고 이전 방법과 동일한 로그가 출력되었습니다. 어떤 아이디어?
내
#!/bin/bash
을 사용하고 있기 때문에bash
에 대한 필요가 없습니다. 스크립트가 종료 된 후 ssh-agent가 실행됩니다. – IBam