How to push to bitbucket using intellij - windows

I have created a project in bitbucket and trying to push code using intellij git. When I created the project bitbucket gave me commands to run within git. Here are the commands I ran and the error I got:
git remote add origin ssh://git#bitbucket.org/[username]/[repo]
git push -u origin master
This looks strange because how is this command suppose to authenticate me? Now here is error I got.
Permission denied (publickey). fatal: Could not read from remote
repository.
Please make sure you have the correct access rights and the repository
exists.
Any ideas?

That is because you are creating your project via ssh and for that you need to create and registrate SSH keys.
Create ssh key
If you don't want that, create your project only via https

Do you have the ssh key added to your computer?
If you're using oSX El Capitan or newer you'll need to add these every time you restart. osx ssh keys
How to add ssh keys

Related

Jenkins git authentication failed with correct credentials on Windows

I'm currently using Jenkins on Windows 10, and using git as version control system.
Although I provided correct repository URL and credential, I cannot use jenkins with error below.
Failed to connect to repository : Command "git.exe ls-remote -h REPOSITORY_URL HEAD" returned status code 128:
stdout:
stderr: git#URL: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Credential and URL doesn't seems wrong, since this build success previously with same credential. The only change after successful build was one line in build script.
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
After I success with this script, git setting keeps failed. Is there any problem with that line? And how can I fix it?
EDIT
Problem solved! For anyone who has same problem, it was problem with the system user! Since ssh key stores in each user space, jenkins cannot detect where the ssh key located. Therefore, go to 'service' in windows, and change user of jenkins service to the user who has correct ssh key. It solved my problem!
Seems there is some problem in Jenkins.
It cannot locate OpenSSH folder in System32, and so that I cannot get log with it.
That would explain why the main Jenkins controller (aka "master" in old terminology) cannot contact the Git repository (assuming an SSH URL here, with technical remote user account "git")
Try and remove that git configuration to see if the error persists: Git should fall back to its own ssh.exe, packaged with Git For Windows.
As noted by the OP, this only works if said Jenkins is run as a user account, not as the system account.
Only then will it be able to access the %USERPROFILE%\.ssh folder.

Visual Studio - Git clone fails over SSH, but works over HTTPS

I am using a fresh install of Visual Studio 2017 (15.8.1), and Git tools.
When I try to clone an existing GitHub repository, either by using the commandline tools, or by using git tools, I receive the following error message:
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
I believe this error is caused by SSH and I cannot seem to make git use HTTPS. Thanks in advance.
If you are using 2-factor authentication at GitHub
You must either do one of the following:
Use the SSH link, add an SSH key to your GitHub account and load it using the SSH agent in Windows, this may be done using Putty.
Generate a personal access token, and use the HTTPS link. Use your GitHub username as the username, but use the generated access token as your password.
If you want to clone any repository using https
Simply clone it using the HTTPS-link instead of the SSH link. You can find both links here, by clicking on Use SSH, you can switch to the SSH link:
In my case, I had to delete ~/.ssh/known_hosts file, so that a new one will be made next time you access git over ssh.

Xcode - Authentication failed error when adding repository with SSH auth

I am trying to add repository via Xcode > Settings > Accounts and I am stuck on the proper address. Address of our repo is quite simple: my.domain.com:port/project-name. Authentication via SSH Keys. Could someone help me to understand what's going on here? See screenshot below.
By the way running git clone git+ssh://git#my.domain.com:port/project-name works fine.
EDIT
Running git clone without git+ssh//
git clone git#my.domain.cz:2222/project-name
or
git clone git#my.domain.cz:22/project-name
is giving me same error:
ssh: connect to host my.domain.cz port 22: Connection refused
fatal: Could not read from remote repository
Please make sure you have the correct access rights and the repository exists.
Xcode accepts just ssh://git#my.domain.cz:2222/project-name.
The git protocol is somehow redundant in this case. Raw git tools don't have a problem with it, but Xcode does not like it for some reason.
It always fails for me when I use existing ssh keys.
I created a new ssh key pair through Xcode and uploaded the public key to the git server (in my case, Phabricator), and it works.

Is stash only meant for sourcetree as its not able to do it from command line in windows?

Is Stash only meant for Sourcetree, as it's not able to do it from console in windows? I have cloned the project from stash.
But I'm unable to push or pull from command prompt, whereas I can do it from Sourcetree to that particular project folder.
Error:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
So is it separately treated or am I doing anything wrong in SSH key setup? Is it a mistake of source tree or Windows machine?
Last question:
How can I add multiple ssh keys for different account to it because default directory is: C:\Users\%user%\.ssh
Stash works with any git client. It looks like your command line client is not using the same SSH key as you're using from SourceTree

Unable to clone git repository from siteground

I'm trying to set up MS WebMatrix to use a Git repository from my siteground hosting account. I created the repository using their cpanel plugin and it tells me that I can clone it using this command
git clone ssh://username#sm3.siteground.biz:18765/home/username/public_html/
I replaced username of course and I created an rsa key using ssh-keygen. In the Webmatrix GUI it just opens a window saying "Clone is in progress" but it doesn't to anything.
And when I run that command in PowerShell, this is the output:
Cloning into 'public_html'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Any help is highly appreciated!
EDIT:
I haven't used github before but I'm pretty sure I'm not connecting to it. The repository is on siteground's server I think. Anyway, I couldn't figure it out in PowerShell so now I'm using putty to load the appropriate key and connect using an external git tool (source tree) that doesn't use the same ssh client as PowerShell. That is the solution that's working for me now.
I'll leave this question open as maybe someone comes around and can help with how to set this up using PowerShell.
The missing piece to the Siteground guide is:
Create a blank file in ~/.ssh/ or C:\Users\username\.ssh on your computer. It does not matter what you name it. I named it siteground_dsa. You could also name it id_dsa_siteground.
Copy the private ssh key that you get from siteground.com and paste the whole of it in the this newly created file.
Open Git Bash locally on your computer and run the following command
$ eval ssh-agent -s
Then run the following. Remember to use the filename that you gave it.
$ ssh-add ~/.ssh/siteground_dsa
Now you need to enter the passphrase for the ssh key. You will have defined it when creating the ssh key.
Now you should be logged in and you can run git clone the directory of your wish.
git clone ssh://username#ams14.siteground.eu:18765/home/username/public_html/
To permanently add the SSH key extend ~/.ssh/config with the following and updating server_name and username.
Host server_name
User username
Port 18765
IdentityFile ~/.ssh/siteground_dsa
keep in mind that for Windows operators, you should write eval $(ssh-agent)
eval $(ssh-agent)
chmod 600 file_name
ssh-add C:\Users\username\.ssh\siteground
Then you can easily clone your file into your local server following inserting your passphrase of the SSH key.
GitHub isn't able to authenticate you. Probably your key isn't associated with your GitHub account.
Take a look to GitHub's recommended method

Resources