Using SCP in BuildStep script

Hello,

I'm executing Tests on a remote machine via WebServices. The result files  of the tests are located on the remote machine. I want to copy them from the remote machine via a powershell or commandshell buildstep into the working directory of my build agent. I'm using key based authentification. When I issue the command from the working dir on the build agent it works. If I'm using the command from the buildstep it doesn't.

 

Im using:

scp -C -r -v -p -i ./id_rsa administrator@192.19.253.28:/D:/Result.xml ./testResultLocal.xml

The interesting part in the log shows:

12:31:04][Step 7/9] debug1: identity file ./id_rsa type -1

It seems that scp is not accepting the private key, any ideas why this happens during the buildstep? Any help is appreciated, I'm kind of lost at the moment. We are using Teamcity 10 Enterprise ...

Thanks for your help.

Mark

 

Complete Log:

[Step 7/9] Executing: program /usr/bin/ssh host 192.19.253.28, user administrator, command scp -v -r -p -f /D:/Result.xml
[12:31:04][Step 7/9] OpenSSH_7.3p1, OpenSSL 1.0.2h 3 May 2016
[12:31:04][Step 7/9] debug1: Reading configuration data /etc/ssh/ssh_config
[12:31:04][Step 7/9] debug1: Connecting to 192.19.253.28 [192.19.253.28] port 22.
[12:31:04][Step 7/9] debug1: Connection established.
[12:31:04][Step 7/9] debug1: key_load_public: No such file or directory
[12:31:04][Step 7/9] debug1: identity file ./id_rsa type -1
[12:31:04][Step 7/9] debug1: key_load_public: No such file or directory
[12:31:04][Step 7/9] debug1: identity file ./id_rsa-cert type -1
[12:31:04][Step 7/9] debug1: Enabling compatibility mode for protocol 2.0
[12:31:04][Step 7/9] debug1: Local version string SSH-2.0-OpenSSH_7.3
[12:31:04][Step 7/9] debug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_7.7
[12:31:04][Step 7/9] debug1: match: OpenSSH_for_Windows_7.7 pat OpenSSH* compat 0x04000000
[12:31:04][Step 7/9] debug1: Authenticating to 192.19.253.28:22 as 'administrator'
[12:31:04][Step 7/9] debug1: SSH2_MSG_KEXINIT sent
[12:31:04][Step 7/9] debug1: SSH2_MSG_KEXINIT received
[12:31:04][Step 7/9] debug1: kex: algorithm: curve25519-sha256@libssh.org
[12:31:04][Step 7/9] debug1: kex: host key algorithm: ecdsa-sha2-nistp256
[12:31:04][Step 7/9] debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
[12:31:04][Step 7/9] debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
[12:31:04][Step 7/9] debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
[12:31:04][Step 7/9] debug1: Server host key: ecdsa-sha2-nistp256 SHA256:Ilh+r6Nrk0AbTZxxHmpmBbR2/DrrevtAckqNv+D35+c
[12:31:04][Step 7/9] debug1: read_passphrase: can't open /dev/tty: No such device or address
[12:31:04][Step 7/9] Host key verification failed.
0
1 comment

Hi Mark,

Sorry for the delay. What kind of build step are you using? Command line? Some sort of scripting? Or SSH Upload? Any reason not to use the SSH Agent feature (https://confluence.jetbrains.com/display/TCD18/SSH+Agent)?

Judging from the end of the debug log, it seems like it's trying to open a tty to read the passphrase and it obviously can't (as teamcity's spawned processes are non-interactive). This could mean that it's actually reading the key properly (or at least some key) and trying to open it (which requires a passphrase), unless I'm misunderstanding something. Could you check that?

0

Please sign in to leave a comment.