Error: "stderr: ssh_exchange_identification: read: Connection reset by peer" during connection
Asked by Marrx1:

Hi everyone! no so long ago faced issue with connection to bitbacket .

For some reason I started getting errors during connection to repo :

```
stderr: ssh_exchange_identification: read: Connection reset by peer
```

These issues appear randomly in my jobs on jenkins, firstly I got error using login and password instead ssh but looking for a solution changed credential to ssh but it doesn't help . My SSH key works because 50% of time it connects successfully but other 50% failed . Could somebody please help me fix this annoying issue?

here the log from jenkins

```
Started by user devBuilding in workspace /var/lib/jenkins/workspace/**********using credential ********-*****-*****-****-*********** > git rev-parse --is-inside-work-tree # timeout=10Fetching changes from the remote Git repository > git config remote.origin.url git@bitbucket.org:******/******.git # timeout=10Fetching upstream changes from git@bitbucket.org:******/********.git > git --version # timeout=10using GIT_SSH to set credentials  > git fetch --tags --progress git@bitbucket.org:******/******.git +refs/heads/*:refs/remotes/origin/*ERROR: Error fetching remote repo 'origin'hudson.plugins.git.GitException: Failed to fetch from git@bitbucket.org:Tailorbet/api-tests-git.git	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:894)	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1161)	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192)	at hudson.scm.SCM.checkout(SCM.java:504)	at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)	at hudson.model.Run.execute(Run.java:1816)	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)	at hudson.model.ResourceController.execute(ResourceController.java:97)	at hudson.model.Executor.run(Executor.java:429)Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@bitbucket.org:*******/*********.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:stdout: stderr: ssh_exchange_identification: read: Connection reset by peerfatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761)	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72)	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442)	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:892)	... 11 moreERROR: Error fetching remote repo 'origin'
```


Answers:
author: Marrx1
body: Currently resolved, we didn't have part of IPs in our whitelists

here the link to check actual Bitbacket IPs

<https://support.atlassian.com/bitbucket-cloud/docs/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall/>


Tags: bitbucket-cloud

cloud