How to add password and port to sshEndpoint on SSH@0 task in ADO?

Viewed 97

Code:

- task: SSH@0
  displayName: 'Run shell inline on remote machine'
  inputs:
    **sshEndpoint: username@server.com**
    runOptions: inline
    inline: |
     cd /
     /usr/documents/mql
     push context user random pass random;
     print context;

I am having issues trying to figure out how to add the password and port to the sshEndpoint input.. there's no documentation on syntax that I'm able to find!If you have tips on where to find these documentations pls lmk

1 Answers

According to your description, you are using SSH task in YAML pipelines. For more about this task, please refer to this following document:

SSH Deployment task - Azure Pipelines | Microsoft Docs.

To use the task, you could fill a SSH service connection name in the sshEndpoint input. The task will try to access the remote machine with the service connection settings.

First, you need to create a SSH service connection. Please navigate to Project settings and then click into the Service connections tab. You could create a new service connection as below:

enter image description here

In the service connection, please add your host, port, username and password. Alternatively, you could also choose to use the private key file to get authentication. It's optional.

enter image description here

When the service connection is created, you could copy the service connection name and paste it into the sshEndpoint input. Please see the example below.

- task: SSH@0
  displayName: 'Run shell inline on remote machine'
  inputs:
    sshEndpoint: 'my_service_connection_name'
    runOptions: inline
    inline: |
     cd / && ls
Related