SSH over HTTPS connection failure debugging
Asked by Luca Maurelli:

I'm trying to setup SSH over HTTPS. I'm on Windows, using OpenSSH trough Git. I have already created the keys and set the configuration for the alternative ssh server from the [guide](https://confluence.atlassian.com/bbkb/cloning-from-bitbucket-cloud-via-ssh-fails-with-port-22-network-is-unreachable-1223821420.html). I tried testing the connection with the command:

```
ssh -Tvvv git@bitbucket.org
```

But there is a connection error. I need help debugging it, due the fact that every source of information related to the error referes to the fact that "you tried SSH over an HTTPS server" which is what I'm suppoing to do to bypass the 22 port and make use of 443 thanks to atlassian. Here the log:

```
$ ssh -Tvvv git@bitbucket.org
OpenSSH_9.6p1, OpenSSL 3.2.1 30 Jan 2024
debug1: Reading configuration data /c/Users/maurell/.ssh/config
debug1: /c/Users/maurell/.ssh/config line 1: Applying options for *
debug1: /c/Users/maurell/.ssh/config line 23: Applying options for bitbucket.org
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/c/Users/maurell/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/c/Users/maurell/.ssh/known_hosts2'
debug2: resolving "altssh.bitbucket.org" port 443
debug3: resolve_host: lookup altssh.bitbucket.org:443
debug3: channel_clear_timeouts: clearing
debug3: ssh_connect_direct: entering
debug1: Connecting to altssh.bitbucket.org [104.192.142.46] port 443.
debug3: set_sock_tos: set socket 4 IP_TOS 0x48
debug1: Connection established.
debug1: identity file /c/Users/maurell/.ssh/bitbucket_work type 3
debug1: identity file /c/Users/maurell/.ssh/bitbucket_work-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.6
debug1: kex_exchange_identification: banner line 0: <HEAD><TITLE>Invalid HTTP Request</TITLE></HEAD>
debug1: kex_exchange_identification: banner line 1: <BODY BGCOLOR="white" FGCOLOR="black"><H1>Invalid HTTP Request</H1><HR>
debug1: kex_exchange_identification: banner line 2: <FONT FACE="Helvetica,Arial"><B>
debug1: kex_exchange_identification: banner line 3: Description: Bad request syntax</B></FONT>
debug1: kex_exchange_identification: banner line 4: <HR>
debug1: kex_exchange_identification: banner line 5: <!-- default "Invalid HTTP Request" response (400) -->
debug1: kex_exchange_identification: banner line 6: </BODY>
kex_exchange_identification: banner line contains invalid characters
banner exchange: Connection to 104.192.142.46 port 443: invalid format

```

The key information is "kex_exchange_identification: banner line contains invalid characters"


Answers:
author: Ben
body: Hi Luca,

If your SSH key is properly configured - can you try performing a clone as outlined in [our guide](https://confluence.atlassian.com/bbkb/port-22-is-blocked-on-local-network-1168865232.html) and let me know what the output is?

    git clone ssh://git@altssh.bitbucket.org:443/<WorkspaceID>/<repo_slug>/

Cheers!

- Ben (Bitbucket Cloud Support)

comments: author: Luca Maurelli
body: Running it inside the git bash terminal from Windows:

```

$ git clone ssh://git@altssh.bitbucket.org:443/<WorkspaceID>/<repo_slug>/
Cloning into '<repo_slug>'...
banner exchange: Connection to xxx.xxx.xxx.xxx port 443: invalid format
fatal: Could not read from remote repository.

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


author: Ben
body: Hi Luca,

Sorry - just to clarify, did you replace the \<workspaceID\> and \<repo_slug\> placeholder values with your actual WorkspaceID and RepositorySlug (without \<\> characters)?

I should have clarified that the placeholders should have been replaced earlier, my apologies. I've just tested cloning on my repository using this command and it was successful - as long as your SSH key has been correctly configured you should be able to perform the clone without issues.

Cheers!

- Ben (Bitbucket Cloud Support)


author: Luca Maurelli
body: Yes, I have replaced both workspaceID and repo_slug placeholder.


author: Ben
body: Hi [@Luca Maurelli](/t5/user/viewprofilepage/user-id/5490862)

I can see that you are a member of a Premium workspace and therefore this entitles you to private, 1:1 support with our Atlassian support team.

I have raised a ticket on your behalf in my timezone (GMT+10) for further assistance, please check your email to discuss this further and let me know what timezone you are in so that I may hand it over to the relevant team if you operate outside of my working hours.

Cheers!

- Ben (Bitbucket Cloud Support)


author: Luca Maurelli
body: Thank you Ben, I have just replied back through email


Tags: bitbucket-cloud

cloud