0

I've made a web hook with bitbucket, and everything is working fine except the post build script, I'm trying to execute a shell command to push the build on the staging server, for some odd reason the shell hangs/loads forever after successfully logging in to the server using ssh key

here are my commands :

sudo ssh -tt -i ~/.ssh/id_rsa user@ip
cd default
git commit -am "inc Jenkins"
git pull origin master
composer install
npm install

The shell never finishes after executing the first line.

enter image description here

On the other side (The staging server), the auth log gave me this once the shell starts hanging : did not receive identification string from *****

Tghosh
  • 180
  • 3
  • 14
  • What shell is the remote user set to have? Are there any special directives in the `authorized_keys` line on the remote server for that key file? – Kenster Apr 20 '20 at 12:29
  • Its -bash And no it doesnt have any special directives in the authorized_keys file. they just have a comment of the key name and the public ssh key. – Tghosh Apr 20 '20 at 12:36

1 Answers1

2

The post build step works exactly as you set it: logins to interactive remote terminal. As no further input is given, the step hangs indefinitely.

To make it work, you need to pass the desired commands using SSH syntax:

ssh -i ~/.ssh/id_rsa user@ip "cd default;git commit -am \"inc Jenkins\";git pull origin master;composer install;npm install;exit"

I omit the -tt as remote execution doesn't need it; you may want to keep it for some edge cases.

doz10us
  • 765
  • 7
  • 17
  • Dude thank you so much for this. It worked But i just had to add sudo at the beginning because it gave me permission denied (Public key), this allowed it and gave it permission to obtain the key (I also had to give jenkins user permissions..etc) Thank you again! – Tghosh Apr 20 '20 at 16:21