Всем привет! Хочу настроить себе CI/CD.
Имеется VDS с gitlab + vds с проектами. Добавил ssh ключи везде. Могу подключиться с сервера на другой сервер, ключи вроде как работают.
Но когда дело доходит до запуска заданий то в gitlab выводится ошибка
ERROR: Preparation failed: ssh command Connect() error: ssh Dial() error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password publickey], no supported methods remain
Запустил debug на сервере где gitlab-runner запущен.
Выводит это:
/usr/sbin/sshd -d -p 2200
debug1: sshd version OpenSSH_7.4, OpenSSL 1.0.2u 20 Dec 2019
debug1: private host key #0: ssh-rsa SHA256:
debug1: private host key #1: ecdsa-sha2-nistp256 SHA256:
debug1: private host key #2: ssh-ed25519 SHA256:
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-d'
debug1: rexec_argv[2]='-p'
debug1: rexec_argv[3]='2200'
debug1: Set /proc/self/oom_score_adj from 0 to -1000
debug1: Bind to port 2200 on 0.0.0.0.
Server listening on 0.0.0.0 port 2200.
debug1: Bind to port 2200 on ::.
Server listening on :: port 2200.
debug1: Server will not fork when running in debugging mode.
debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8
debug1: inetd sockets after dupping: 3, 3
Connection from 000.00.000.00 port 37910 on 000.00.000.00 port 2200
debug1: Client protocol version 2.0; client software version Go
debug1: no match: Go
debug1: Local version string SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u7
debug1: Enabling compatibility mode for protocol 2.0
debug1: permanently_set_uid: 108/65534 [preauth]
debug1: list_hostkey_types: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
debug1: SSH2_MSG_KEXINIT sent [preauth]
debug1: SSH2_MSG_KEXINIT received [preauth]
debug1: kex: algorithm: curve25519-sha256@libssh.org [preauth]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256 [preauth]
debug1: kex: client->server cipher: aes128-gcm@openssh.com MAC: compression: none [preauth]
debug1: kex: server->client cipher: aes128-gcm@openssh.com MAC: compression: none [preauth]
debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
debug1: rekey after 4294967296 blocks [preauth]
debug1: SSH2_MSG_NEWKEYS sent [preauth]
debug1: expecting SSH2_MSG_NEWKEYS [preauth]
debug1: SSH2_MSG_NEWKEYS received [preauth]
debug1: rekey after 4294967296 blocks [preauth]
debug1: KEX done [preauth]
debug1: userauth-request for user root service ssh-connection method none [preauth]
debug1: attempt 0 failures 0 [preauth]
debug1: PAM: initializing for "root"
debug1: PAM: setting PAM_RHOST to "000.00.000.00"
debug1: PAM: setting PAM_TTY to "ssh"
debug1: userauth-request for user root service ssh-connection method password [preauth]
debug1: attempt 1 failures 0 [preauth]
Failed none for root from 000.00.000.00 port 37910 ssh2
debug1: userauth-request for user root service ssh-connection method publickey [preauth]
debug1: attempt 2 failures 1 [preauth]
debug1: userauth_pubkey: test whether pkalg/pkblob are acceptable for RSA SHA256:[preauth]
debug1: temporarily_use_uid: 0/0 (e=0/0)
debug1: trying public key file /root/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 0/0 (e=0/0)
debug1: trying public key file /root/.ssh/authorized_keys2
debug1: fd 4 clearing O_NONBLOCK
debug1: restore_uid: 0/0
Failed publickey for root from 000.00.000.00 port 37910 ssh2: RSA SHA256:
Connection closed by 000.00.000.00 port 37910 [preauth]
debug1: do_cleanup [preauth]
debug1: monitor_read_log: child log fd closed
debug1: do_cleanup
debug1: PAM: cleanup
debug1: Killing privsep child 6731
debug1: audit_event: unhandled event 12
Само задание:
pages:
stage: deploy
before_script:
- 'command -v ssh-agent >/dev/null || ( apk add --update openssh )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p .ssh
- chmod 700 .ssh
- ssh-keyscan $VM_IPADDRESS >> .ssh/known_hosts
- chmod 644 .ssh/known_hosts
script:
- ssh $SSH_USER@$VM_IPADDRESS 'cd /home/a-furgon/a-furgon.grphn-dev.ru/www && git reset --hard && git pull origin && cd www && npm i --prefer-offline --no-audit --progress=false && cd src/js && npm i --prefer-offline --no-audit --progress=false && cd ../.. && gulp build'
only:
- main
Переменные настроены верно.
Что еще посмотреть?