phpgitdockersshgitlab

docker gitlab-ci ssh php-web, get read_passphrase: can't open /dev/tty: No such device or address


ssh debug show that

debug1: Next authentication method: publickey
debug1: Offering public key: /dev/fd/63 RSA SHA256:xxxxxxxxxxxxxxxxxx agent
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Trying private key: /root/.ssh/id_xmss
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: No more authentication methods to try.
xxxxxxx@xxxxxxxx: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
lost connection

gitlab-ci.yml

stages:
  - deploy
before_script:
  - echo "ssh-user:$SSH_USER"
  - echo "ssh-host:$SSH_HOST"
  - echo "ci-pro-dir:$CI_PROJECT_DIR"
  - export PATH=/usr/local/bin:$PATH
  - '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
  - chmod 700 ~/.ssh
  - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
  - chmod 644 ~/.ssh/known_hosts
  - '[[ -f /.dockerenv ]] && echo -e "Host *\\n\\tStrictHostKeyChecking no\\n\\n" > ~/.ssh/config'
variables:
  SERVER_PATH: "/home/xxx/www/xxxx"
docker-deploy:
  stage: deploy
  script:
    - scp -v -r $CI_PROJECT_DIR $SSH_USER@$SSH_HOST:$SERVER_PATH
  tags:
    - xxx-xxx
  only:
    - master

use ssh to scp file-folder, but show read_passphrase: can't open /dev/tty: No such device or address

there are "/dev/tty" exists

no idea to solve, should i delete "/dev/tty" and rebuild it?


Solution

  • Can you please try to simply ssh to the host from shell? In this case we would see if SSH is possible without debugging gitlab-ci