title: Bitbuket pipeline - how to set ssh
body: <p>When my pipeline runs, I am getting the below errors:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>This is my .yml file:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>What I have tried is that chmod the ~/.ssh folder and files there to 777</p>
  
  <p>The hostName variable is set in the repositories' settings.</p>
  
  <p>Re-generated the key. Pasted in the authorize_keys file in the remote server, but I'm still getting the same error</p>
  
  <p>Location of authorized_keys:</p>
  
  <p><a href="https://i.stack.imgur.com/bfds6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bfds6.png" alt="enter image description here"></a></p>
  
  <p>================================================================</p>
  
  <p>This is what is working:</p>
  
  <ol>
  <li>Deleted the SSH keys from bitbucket's pipeline's.</li>
  <li>Generated the SSH key on the remote server by using: ssh-keygen</li>
  <li>Used default for the above command, and don't set passphrase.</li>
  <li>Default location where keys are generated is: /root/.ssh</li>
  <li>.ssh folder is hidden. Using winSCP you can unhide the hidden folders.</li>
  <li>Copied the content of id_rsa.pub from remote server and pasted into bitbucket's SSH.</li>
  <li>Created authorized_keys with the contents of id_rsa.pub inside /root/.ssh</li>
  <li>Copied the the content of id_rsa from the remote server and pasted into bitbucket's SSH.</li>
  <li><p>This copies the jar to the remote server:</p>
  
  <ul>
  <li>scp -i /root/.ssh -4 -P 7822 -v -o StrictHostKeyChecking=no target/*.jar root@$hostName:/var/transpoDirect/.</li>
  </ul></li>
  <li><p>This restarts the service as described here: <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html" rel="nofollow noreferrer">https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html</a></p>
  
  <ul>
  <li>ssh -4 -p 7822 -i /root/.ssh -v -o StrictHostKeyChecking=no root@$hostName sudo service transpoDirect restart</li>
  </ul></li>
  </ol>