docker gitlab-ci s sh php -web, получить read_passphrase: невозможно открыть / dev / tty: такого устройства или адреса нет - PullRequest
0 голосов
/ 08 апреля 2020

s sh отладка показывает, что

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

использует s sh для поиска файловой папки, но показывает read_passphrase: can ' t open / dev / tty: такого устройства или адреса

не существует, существует "/ dev / tty"

понятия не имею, могу ли я удалить "/ dev / tty" и перестроить его

Ответы [ 3 ]

0 голосов
/ 10 апреля 2020

@ Георгий Гоглодзе

пробовал, тоже не работает. ключ pub был указан для author_keys, закрытый ключ был отправлен агенту s sh с помощью используемой переменной

$ scp -o StrictHostKeyChecking=no -v -r $CI_PROJECT_DIR $SSH_USER@$SSH_HOST:$SERVER_PATH
Executing: program /usr/bin/ssh host xxx.xx.xxx.xxx, user root, command scp -v -r -t /home/dnmp/www/icitysecret_backend
OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to xxx.xx.xxx.xxx [xxx.xx.xxx.xxx] port 22.
debug1: Connection established.
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u2
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to xxx.xx.xxx.xxx:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxx
Warning: Permanently added 'xxx.xx.xxx.xxx' (ECDSA) to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: root@xxxxxxxxxxxxxx RSA SHA256:xxxxxxxxxxxxxxxxxxx agent
debug1: Will attempt key: /root/.ssh/id_rsa 
debug1: Will attempt key: /root/.ssh/id_dsa 
debug1: Will attempt key: /root/.ssh/id_ecdsa 
debug1: Will attempt key: /root/.ssh/id_ed25519 
debug1: Will attempt key: /root/.ssh/id_xmss 
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_0)


debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_0)


debug1: Next authentication method: publickey
debug1: Offering public key: root@xxxxxxxxxxxxxxxxx RSA SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxx 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.
root@xxx.xx.xxx.xxx: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
lost connection
0 голосов
/ 11 апреля 2020

Можете ли вы просто попробовать sh на хост из оболочки? В этом случае мы увидим, возможен ли S SH без отладки gitlab-ci

0 голосов
/ 08 апреля 2020

Я бы попробовал следующее:
1. Сначала создайте пару открытых / закрытых ключей rsa.
2. Скопируйте публикуемый c ключ с авторизованным ключом:

cat ~/.ssh/id_rsa.pub | ssh $SSH_USER@$SSH_HOST'cat >> ~/.ssh/authorized_keys'
...