Git and Bitbucket without SSH
Asked Answered
C

4

28

I've set up a local git repository on my computer, and I'm trying to push that to a newly created Bitbucket account.

The problem is that Bitbucket gives me an ssh url to push to, but the network I'm on (university) has the ssh port blocked for external ssh. So that fails, and if I try to replace ssh:// with https:// it keeps telling me that authentication has failed.

Is there a way to push to bitbucket without using ssh?

Cornel answered 17/5, 2013 at 11:39 Comment(0)
N
55

You can connect to GitHub and Bitbucket repositories via HTTPS. Both will also let you push.

These are the typical URLs for HTTPS access:

https://[email protected]/username/repository.git
https://github.com/username/repository.git

Note that Git will prompt you for your password whenever you want to communicate with the remote.

Nedneda answered 17/5, 2013 at 11:54 Comment(5)
Note that if you want to commit to a team project on Bitbucket, the first username is your own username, the second username is the team name. So to connect as "username" to "repository" by "teamname", the URL would be https://[email protected]/teamname/repository.gitGaudette
The typical URLs are possible only to push a text file not binary like image files.Supersaturated
@hyip Not sure where you got that idea from. You can totally push binary files via HTTPS. It would be very weird for GitHub and Bitbucket to advertise Git access via HTTPS as default if there were such restrictions.Nedneda
@Nedneda Yes, I agree for https of GitHub, we can push images on GitHub's https via "+ New File" menu. While on Bitbucket's https, the "+ New File" is only for a Plain text file.Supersaturated
@hyip You do realize that this is not about some web interface? This is the Git command line using a HTTPS address as a remote URL.Nedneda
R
3

I wanted to add that SourceTree somehow wants it without the username:

https://bitbucket.org/username/repository.git
Ruthenic answered 5/11, 2014 at 17:47 Comment(1)
I think it is important to mention that this works for .git/config as well.Tomchay
T
0

If they've blocked the port, but not the protocol, you can use SSH over the HTTPS port on several major code hosts.

You could probably accomplish this with carefully crafted remotes in your repository configuration, but it's much easier to ask SSH to remap those connections for your whole user account. This goes in ~/.ssh/config:

Host bitbucket.org
    HostName altssh.bitbucket.org
    Port 443

Host github.com
    HostName ssh.github.com
    Port 443

Host gitlab.com
    HostName altssh.gitlab.com
    Port 443

Also, for kicks, you can add RequestTTY no and User git to each block to make it easy to ssh -v github.com to debug connections. (Bonus: adding hosts to SSH config makes them tab-complete.)

Tomchay answered 8/2, 2023 at 18:25 Comment(0)
P
-2

Have you tried using?

[email protected]:accountname/reponame.git

You may take a look here

Pushover answered 17/5, 2013 at 11:43 Comment(3)
That’s just the short syntax for an SSH connection.Nedneda
poke, I'm inclined to believe this, but is there some documentation which confirms your assertion?Subalpine
1) It's the text you get from your bitbucket.org account's main page when you select SSH 2) if you try it and can't access port 22 it failsVasectomy

© 2022 - 2024 — McMap. All rights reserved.