Cannot connect via Team Foundation Server SSH protocol

Bitrise Build Issue Report template

Description of the issue

Hi! Im facing some trouble with build configuration over ssh protocol with Team Foundation server. The SSH Key is registered in my account on TFS, but SSH fails with Permission Denied error. The SSH url is this:

ssh://USERNAME@SERVERNAME:22/PATHTOREPO

My build log:

version: 1.16.0

INFO[13:25:26] bitrise runs in CI mode
INFO[13:25:26] pattern (validation/with-ssh) triggered workflow (validation_workflow_with_ssh)

Switching to workflow: validation_workflow_with_ssh

±-----------------------------------------------------------------------------+
| (0) Activate App SSH key |
±-----------------------------------------------------------------------------+
| id: activate-ssh-key |
| version: 3.1.1 |
| collection: https://github.com/bitrise-io/bitrise-steplib.git |
| toolkit: bash |
| time: 2018-05-17T13:25:30Z |
±-----------------------------------------------------------------------------+

Fetched 6,282 kB in 3s (2,091 kB/s)

INFO[13:25:39] Start installing (expect) with apt-get
INFO[13:25:39] * [OK] Step dependency (expect) installed, available.
INFO[13:25:39] Start installing (git) with apt-get
INFO[13:25:39] * [OK] Step dependency (git) installed, available.

Configuration

  • Path to save the RSA SSH private key: /root/.ssh/steplib_ssh_step_id_rsa
  • Should remove other identities from the ssh-agent? true
    -> $ mkdir -p /root/.ssh
    -> $ chmod 0600 /root/.ssh/steplib_ssh_step_id_rsa
    Could not open a connection to your authentication agent.
    (i) ssh_agent_check_result: 2
    (i) ssh-agent not started
    (i) starting a new ssh-agent and exporting connection information with envman
    Agent pid 582
    (i) Expose SSH_AUTH_SOCK for the new ssh-agent, with envman
    spawn ssh-add /root/.ssh/steplib_ssh_step_id_rsa
    Identity added: /root/.ssh/steplib_ssh_step_id_rsa (/root/.ssh/steplib_ssh_step_id_rsa)

Success

The SSH key was saved to /root/.ssh/steplib_ssh_step_id_rsa
and was successfully added to ssh-agent.
| |
±–±--------------------------------------------------------------±---------+
| ✓ | Activate App SSH key | 12 sec |
±–±--------------------------------------------------------------±---------+

±-----------------------------------------------------------------------------+
| (1) Git Clone Repository |
±-----------------------------------------------------------------------------+
| id: git-clone |
| version: 3.4.3 |
| collection: https://github.com/bitrise-io/bitrise-steplib.git |
| toolkit: go |
| time: 2018-05-17T13:25:41Z |
±-----------------------------------------------------------------------------+
| |
INFO[13:25:41] Start installing (golang) with apt-get
INFO[13:25:41] * [OK] Step dependency (go) installed, available.

Git Clone Configs:

  • CloneIntoDir: /bitrise/src
  • RepositoryURL: ssh://#######
    Git Checkout Configs:
  • Commit:
  • Tag:
  • Branch: master
  • CloneDepth:
    Git Pull Request Configs:
  • PullRequestURI:
  • PullRequestID:
  • BranchDest:
  • PullRequestMergeBranch:
  • ResetRepository: No
    Bitrise Build Configs:
  • BuildURL:
  • BuildAPIToken:

Git clone repository
=> git “init”
=> git “remote” “add” “origin” “ssh://########”
=> git “fetch”
0 attempt failed:
Warning: Permanently added ‘tfs.iterative.com.br,201.16.245.209’ (ECDSA) to the list of known hosts.
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Retrying…
=> git “fetch”
1 attempt failed:
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Retrying…
=> git “fetch”
2 attempt failed:
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Failed, error: Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

| |
±–±--------------------------------------------------------------±---------+
| x | Git Clone Repository (exit code: 1) | 13 sec |
±–±--------------------------------------------------------------±---------+
| Update available: 3.4.3 -> 4.0.11 |
| Issue tracker: https://github.com/bitrise-io/steps-git-clone/issues |
| Source: https://github.com/bitrise-io/steps-git-clone |
±–±--------------------------------------------------------------±---------+

INFO[13:25:52] Step uses latest version – Updating StepLib …
INFO[13:25:52] Update StepLib (https://github.com/bitrise-io/bitrise-steplib.git)…
±-----------------------------------------------------------------------------+
| (2) Running project scanner |
±-----------------------------------------------------------------------------+
| id: project-scanner |
| version: 1.6.3 |
| collection: https://github.com/bitrise-io/bitrise-steplib.git |
| toolkit: bash |
| time: 2018-05-17T13:26:00Z |
±-----------------------------------------------------------------------------+
| |
WARN[13:26:00] A previous step failed, and this step (Running project scanner) was not marked as IsAlwaysRun, skipped
| |
±–±--------------------------------------------------------------±---------+
| - | Running project scanner | 7.70 sec |
±–±--------------------------------------------------------------±---------+

±-----------------------------------------------------------------------------+
| bitrise summary |
±–±--------------------------------------------------------------±---------+
| | title | time (s) |
±–±--------------------------------------------------------------±---------+
| ✓ | Activate App SSH key | 12 sec |
±–±--------------------------------------------------------------±---------+
| x | Git Clone Repository (exit code: 1) | 13 sec |
±–±--------------------------------------------------------------±---------+
| Update available: 3.4.3 -> 4.0.11 |
| Issue tracker: https://github.com/bitrise-io/steps-git-clone/issues |
| Source: https://github.com/bitrise-io/steps-git-clone |
±–±--------------------------------------------------------------±---------+
| - | Running project scanner | 7.70 sec |
±–±--------------------------------------------------------------±---------+
| Total runtime: 32 sec |
±-----------------------------------------------------------------------------+

What is this issue??? Thanks in advance.

Hi @joaomorais1989,
based on the log it seems you did not properly setup the ssh key authentication.

I tried to integrate a project stored on tfs and it works fine:

  • On bitrise.io Add New App page, when you are on selecting your repository, select the Other/Manual
  • Provide the Git repository (clone) URL
  • For the Do you need to use an additional private repository? question select: No auto add ssh key

This choose will throw an error: Error: Failed to register SSH key for service: custom. Try to register the Public Key manually on custom.

At this point the website will show you the generated ssh key, click on COPY TO CLIKPBOARD to copy the ssh key.

  • On TFS navigate click on your user account (in the right corner) and select Security list item
  • Select SSH public keys
  • Click on Add button and paste your ssh key to the Key Data box, then click on save
  • Go back to bitrise.io and click I've added the SSH key to continue
+------------------------------------------------------------------------------+
| (0) Activate App SSH key                                                     |
+------------------------------------------------------------------------------+
| id: activate-ssh-key                                                         |
| version: 3.1.1                                                               |
| collection: https://github.com/bitrise-io/bitrise-steplib.git                |
| toolkit: bash                                                                |
| time: 2018-05-18T10:53:59Z                                                   |
+------------------------------------------------------------------------------+
|                                                                              |
INFO[10:53:59] sudo "apt-get" "update"                      
....

INFO[10:54:08] Start installing (expect) with apt-get       
INFO[10:54:08]  * [OK] Step dependency (expect) installed, available. 
INFO[10:54:08] Start installing (git) with apt-get          
INFO[10:54:08]  * [OK] Step dependency (git) installed, available. 

# Configuration

* Path to save the RSA SSH private key: */root/.ssh/steplib_ssh_step_id_rsa*
* Should remove other identities from the ssh-agent? *true*
-> $ mkdir -p /root/.ssh
-> $ chmod 0600 /root/.ssh/steplib_ssh_step_id_rsa
Could not open a connection to your authentication agent.
 (i) ssh_agent_check_result: 2
 (i) ssh-agent not started
 (i) starting a new ssh-agent and exporting connection information with envman
Agent pid 582
 (i) Expose SSH_AUTH_SOCK for the new ssh-agent, with envman
spawn ssh-add /root/.ssh/steplib_ssh_step_id_rsa
Identity added: /root/.ssh/steplib_ssh_step_id_rsa (/root/.ssh/steplib_ssh_step_id_rsa)

# Success

The SSH key was saved to */root/.ssh/steplib_ssh_step_id_rsa*
and was successfully added to ssh-agent.
|                                                                              |
+---+---------------------------------------------------------------+----------+
| ✓ | Activate App SSH key                                          | 12 sec   |
+---+---------------------------------------------------------------+----------+

                                          ▼

+------------------------------------------------------------------------------+
| (1) Git Clone Repository                                                     |
+------------------------------------------------------------------------------+
| id: git-clone                                                                |
| version: 3.4.3                                                               |
| collection: https://github.com/bitrise-io/bitrise-steplib.git                |
| toolkit: go                                                                  |
| time: 2018-05-18T10:54:10Z                                                   |
+------------------------------------------------------------------------------+
|                                                                              |
INFO[10:54:10] Start installing (golang) with apt-get       
INFO[10:54:10]  * [OK] Step dependency (go) installed, available. 

Git Clone Configs:
- CloneIntoDir: /bitrise/src
- RepositoryURL: ssh://XYZ@vs-ssh.visualstudio.com:22/_ssh/MyFirstProject
Git Checkout Configs:
- Commit: 
- Tag: 
- Branch: master
- CloneDepth: 
Git Pull Request Configs:
- PullRequestURI: 
- PullRequestID: 
- BranchDest: 
- PullRequestMergeBranch: 
- ResetRepository: No
Bitrise Build Configs:
- BuildURL: 
- BuildAPIToken: 

Git clone repository
=> git "init"
=> git "remote" "add" "origin" "ssh://XYZ@vs-ssh.visualstudio.com:22/_ssh/MyFirstProject"
=> git "fetch"
=> git "checkout" "master"
=> git "submodule" "update" "--init" "--recursive"
Exporting git logs
=> GIT_CLONE_COMMIT_HASH
   value: e9159457c519574ca6e42f2c45f49bba1d1b479c

=> GIT_CLONE_COMMIT_MESSAGE_SUBJECT
   value: First commit

=> GIT_CLONE_COMMIT_MESSAGE_BODY
   value: 

=> GIT_CLONE_COMMIT_AUTHOR_NAME
   value: Krisztián  Gödrei

=> GIT_CLONE_COMMIT_AUTHOR_EMAIL
   value: godreikrisztian@gmail.com

=> GIT_CLONE_COMMIT_COMMITER_NAME
   value: Krisztián  Gödrei

=> GIT_CLONE_COMMIT_COMMITER_EMAIL
   value: godreikrisztian@gmail.com

Success
|                                                                              |
+---+---------------------------------------------------------------+----------+
| ✓ | Git Clone Repository                                          | 12 sec   |
+---+---------------------------------------------------------------+----------+
| Update available: 3.4.3 -> 4.0.11                                            |
+---+---------------------------------------------------------------+----------+
1 Like