0

I'm trying to run an scp command:
scp -i id_rsa /c/GitUtils/Git/hooks/40_pre-receive root@tvlscmd1.snifim.blroot:/root/tmp/
Although the file exist and correct and in the right privileges, I'm still getting a password prompt: root@tvlscmd1.snifim.blroot's password:
I tried to use ssh-add but got Could not open a connection to your authentication agent. I'm using git bash from windows machine.
I run the command with verbose and got:

$ scp -v -i id_rsa /c/GitUtils/Git/hooks/40_pre-receive root@tvlscmd1.snifim.blroot:/root/tmp/
Executing: program /usr/bin/ssh host tvlscmd1.snifim.blroot, user root, command scp -v -t /root/tmp/
OpenSSH_7.5p1, OpenSSL 1.0.2k  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to tvlscmd1.snifim.blroot [10.4.6.83] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.5
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to tvlscmd1.snifim.blroot: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:34+nTjfQldHl2oPETcjgvdbptObDHBZ7k0s2eueu1Z4
debug1: Host 'tvlscmd1.snifim.blroot' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/TvlRtcBuild/.ssh/known_hosts:3
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: 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: publickey
debug1: Trying private key: id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: password
root@tvlscmd1.snifim.blroot's password: 

We can see that the private key is being tried and then moved to password.
I noticed that we are using SELinux so I disabled it and tried again, same result.
Here is the ssh folder int he linux machine (rhel):

[root@TvlScmD1 .ssh]# ll
total 8
-rw-------. 1 root root 3389 May  2 16:57 id_rsa
-rw-r--r--. 1 root root  752 May  2 16:57 id_rsa.pub
drwxr-xr-x. 2 root root   80 May  2 16:56 tmp

Although I wrote that the ssh-add is not working, I'm not suspecting this is the issue. This machine is new (bitbucket upgrade) and in the previous version on an older machine the command works just fine - please reopen this Q. Any help will be appreciate .

soninob
  • 398
  • 8
  • 20
  • To use key-based client auth in SSH, you must **copy the (client) public key _to the authorized_keys file in ~/.ssh on the server_**. In _some_ builds/packages there is a command `ssh-copy-id` to help you do this, but it's not clear which/what you are using, since the Windows-supplied port of OpenSSH doesn't use that syntax for local-side names. – dave_thompson_085 May 03 '22 at 07:38
  • I already copied the public key to the authorized_keys. The key was original created from gtibash using the generate key command ssh-keygen -o -t rsa -b 4096 -C "" – soninob May 03 '22 at 07:46
  • You posted a directory listing from the server that shows **`authorized_keys` does not exist**. Please explain how you put the publickey in a file that doesn't exist. – dave_thompson_085 May 04 '22 at 06:15
  • This is part of my tests, you can see the tmp folder, I moved the file inside the tmp directory when I tried to create a new key. Nevertheless, this is not the issue. We managed to solved it, the problems was that the owner of the ssh directory wasn't root. Once we changed it, everything works. Thank you for trying to help. – soninob May 04 '22 at 11:02

0 Answers0