D
D
drtvader2022-04-14 15:49:13
GitLab
drtvader, 2022-04-14 15:49:13

How to fix GitLab CI/CD error?

Hello! I want to set up CI/CD for myself.
There is a VDS with gitlab + vds with projects. Added ssh keys everywhere. I can connect from the server to another server, the keys seem to work.
But when it comes to running jobs, gitlab throws an error

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


Started debug on the server where gitlab-runner is running.
Outputs this:
/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: [email protected] MAC: compression: none [preauth]
debug1: kex: server->client cipher : [email protected] 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 received [preauth]
debug1: SWSH2_MSG [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


The task itself:
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 [email protected]$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:

The variables are set correctly.
What else to see?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
akelsey, 2022-04-14
@akelsey

I didn’t really understand why it connects somewhere else via ssh?
gitlab-runner on the remote server initiated a connection to gitlab-server under a specific user, you should see the success of this on gitlab-server in web.
send those commands that need to be done on the server where gitlab-runner is running,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question