When my pipeline runs, I am getting the below errors:
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/config
debug1: key_load_private_type: incorrect passphrase supplied to decrypt private key
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
lost connection
This is my .yml file:
image: maven:3.3.9
pipelines:
default:
- step:
caches:
- maven
name: Build
script: # Modify the commands below to build your repository.
- echo "Build Start"
- mvn package
- echo $BUILD_DIR
- mv target/**.jar target/transpoDirect.jar
artifacts:
- target/**.jar
- step:
name: Deploy
image: maven:3.3.9
script:
- ls -la .
- scp -i ~/.ssh/config -P 7822 -v -o StrictHostKeyChecking=no target/*.jar root@$hostName:/var/transpoDirect/.
- ssh -p 7822 -i ~/.ssh/config -v -o StrictHostKeyChecking=no root@$hostName sudo service transpoDirect restart
What I have tried is that chmod the ~/.ssh folder and files there to 777
The hostName variable is set in the repositories' settings.
Re-generated the key. Pasted in the authorize_keys file in the remote server, but I'm still getting the same error
Location of authorized_keys:
================================================================
This is what is working:
- Deleted the SSH keys from bitbucket's pipeline's.
- Generated the SSH key on the remote server by using: ssh-keygen
- Used default for the above command, and don't set passphrase.
- Default location where keys are generated is: /root/.ssh
- .ssh folder is hidden. Using winSCP you can unhide the hidden folders.
- Copied the content of id_rsa.pub from remote server and pasted into bitbucket's SSH.
- Created authorized_keys with the contents of id_rsa.pub inside /root/.ssh
- Copied the the content of id_rsa from the remote server and pasted into bitbucket's SSH.
This copies the jar to the remote server:
- scp -i /root/.ssh -4 -P 7822 -v -o StrictHostKeyChecking=no target/*.jar root@$hostName:/var/transpoDirect/.
This restarts the service as described here: https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html
- ssh -4 -p 7822 -i /root/.ssh -v -o StrictHostKeyChecking=no root@$hostName sudo service transpoDirect restart
