user2058839
user2058839

Reputation:

Gerrit scp on Windows 8.1 : permission denied (but ssh test seems to be good)

I'm trying to know why I have a permission design on scp command to automatically add commit Change-Id line for gerrit.

Everything I have found on Internet and StackOverflow about this is about a problem with ssh (as explained here : Permission denied (publickey))

But what is strange is that everything seems to be good when trying an ssh connection:

C:\Development\demo-project\.git\hooks>ssh -vv -p 29418 [email protected]
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug2: ssh_connect: needpriv 0
debug1: Connecting to gerrit.domain.net [5.135.150.179] port 29418.
debug1: Connection established.
debug1: identity file /c/Users/Ga\303\253tan/.ssh/identity type -1
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type 'Proc-Type:'
debug2: key_type_from_name: unknown key type 'DEK-Info:'
debug2: key_type_from_name: unknown key type '-----END'
debug2: key_type_from_name: unknown key type '----'
debug2: key_type_from_name: unknown key type 'Comment:'
debug2: key_type_from_name: unknown key type '----'
debug1: identity file /c/Users/Ga\303\253tan/.ssh/id_rsa type -1
debug1: identity file /c/Users/Ga\303\253tan/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version GerritCodeReview_2.8.5 (SSHD-CORE-0.11.0)
debug1: no match: GerritCodeReview_2.8.5 (SSHD-CORE-0.11.0)
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-md5-96,hmac-sha1-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-md5-96,hmac-sha1-96
debug2: kex_parse_kexinit: none
debug2: kex_parse_kexinit: none
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_init: found hmac-md5
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_init: found hmac-md5
debug1: kex: client->server aes128-cbc hmac-md5 none
debug2: dh_gen_key: priv key bits set: 134/256
debug2: bits set: 993/2048
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host '[gerrit.domain.net]:29418' is known and matches the RSA host key.
debug1: Found key in /c/Users/Ga\303\253tan/.ssh/known_hosts:1
debug2: bits set: 1079/2048
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /c/Users/Ga\303\253tan/.ssh/identity (0x0)
debug2: key: /c/Users/Ga\303\253tan/.ssh/id_rsa (0x0)
debug2: key: /c/Users/Ga\303\253tan/.ssh/id_dsa (0x0)
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Users/Ga\303\253tan/.ssh/identity
debug1: Trying private key: /c/Users/Ga\303\253tan/.ssh/id_rsa
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/c/Users/Gahfy/.ssh/id_rsa':
debug1: read PEM private key done: type RSA
debug2: we sent a publickey packet, wait for reply
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug2: channel 0: send open
debug1: Entering interactive session.
debug2: callback start
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 0
debug2: channel 0: request shell confirm 0
debug2: fd 3 setting TCP_NODELAY
debug2: callback done
debug2: channel 0: open confirm rwindow 2097152 rmax 32768
debug2: channel 0: rcvd ext data 293

  ****    Welcome to Gerrit Code Review    ****

  Hi Gahfy, you have successfully connected over SSH.

  Unfortunately, interactive shells are disabled.
  To clone a hosted Git repository, use:

  git clone ssh://[email protected]:29418/REPOSITORY_NAME.git

debug2: channel 0: written 293 to efd 6
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug2: channel 0: rcvd close
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
Connection to gerrit.domain.net closed.
debug1: Transferred: stdin 0, stdout 0, stderr 45 bytes in 0.7 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 69.1
debug1: Exit status 127

But when I try the scp command:

C:\Development\demo-project\.git\hooks>scp -p -P 29418 gerrit.domain.net:hooks/commit-msg .git/hooks/
Enter passphrase for key '/c/Users/Gahfy/.ssh/id_rsa':
Permission denied (publickey).

May you know the reason of this failure ?

Thank you.

Upvotes: 0

Views: 682

Answers (1)

laplasz
laplasz

Reputation: 3497

I think you are missing the userId from the host. So try adding your Gerrit userId to the command:

scp  -P 29418 <userId>@gerrit.domain.net:hooks/commit-msg .git/hooks/

Upvotes: 2

Related Questions