Gitlab - Push with to remote not working - ssh

I installed Gitlab 6 on my MBP running OS X 10.8.5 and works fine. I can create projects, users, commit, push ... But only from there.
I try to push project from my iMac ( I do git config, init, add, commit), I generated also the ssh keys.
When a test the connection : ssh -T git#my_server it gives "Welcome to Gitlab, Anonymous".
but when I issue the push -u origin master I've got :
Blockquote
Access denied
Fatal: Could not read from remote repository
Please make sure you have the correct access rights and the repository exists.
Blockquote
Is it something relating with SSH or with Gitlab itself ?
In Gitlab 6 a added a 2d key to the project, my public key (generated on the iMac).
On my MBP I added the content of the id_rsa.pub (iMac) to the authorised_keys and known_hosts files (MBP)
Thank.

Related

Git bash on Windows 10 no longer works with Bitbucket since the March 2022 App Password change from Atlassian

I have read 100's of posts and tried dozens of things, give or take, to get Windows 10 and my git bash push to work with the Bitbucket Cloud and their App password mandate enforced on March 1st 2022. I decided to reach out to the stack team before I harm a monitor, laptop or myself. 10 hours in and I give up. Mea Culpa.
Using git bash:
$ git push -u origin master
Gets me:
remote: Bitbucket Cloud recently stopped supporting account passwords for Git authentication.
remote: See our community post for more details:
https://atlassian.community/t5/x/x/ba-p/1948231
remote: App passwords are recommended for most use cases and can be created in your Personal
settings:
remote: https://bitbucket.org/account/settings/app-passwords/
fatal: Authentication failed for 'https://bitbucket.org/myWorkspace/myRepo.git/'
Windows 10
git bash version 2.35.1.windows.2
using bitbucket web interface to view my repositories and add app
passwords --- https://bitbucket.org/
My bitbucket account has my work email address and a username associated with it.
I have a Bitbucket Cloud workspace, project and repository that I have been pushing into for several years.
I have used both Visual Studio and Git Bash to access this repository.
I did not create the repository. Our company admin did.
I am the only user of the repository and the only userid that has ever pushed to it.
Both access methods VS2019 and Git Bash quit working for me around Mar. 10th when I tried my first Commit and Push since Dec2021.
Since my first error on March 10th.
I have added an app password via bitbucket web interface by:
1 - Left click my avatar lower left of bitbucket web page
2 - Select Personal Settings
3 - Select App Passwords on the left
4 - Click Blue Create App Password button
5 - Labeled it: GitBash
6 - Selected all the permissions below -
Account
x - Email
x - Read
x - Write
Workspace membership
x - Read
x - Write
Projects
x - Read
x - Write
Repositories
x - Read
x - Write
x - Admin
not - Delete
Pull requests
x - Read
x - Write
7 - Then hit the blue Create button.
8 - I then got the screen that displayed the 20 char password. I copied it to notepad temporarily and then put it in the git command below:
$ git remote set-url origin https://myUserid:myAppPassword1234567#bitbucket.org/my-workspace/myrepo.git
I then try my push again:
$ git push -u origin master
and get the response:
remote: Bitbucket Cloud recently stopped supporting account passwords for Git authentication.
remote: See our community post for more details: https://atlassian.community/t5/x/x/ba-p/1948231
remote: App passwords are recommended for most use cases and can be created in your Personal settings:
remote: https://bitbucket.org/account/settings/app-passwords/
fatal: Authentication failed for 'https://bitbucket.org/myWorkspace/myRepo.git/'
$ git config --global --list
core.editor="C:\Users\first last\AppData\Local\Programs\Microsoft VS Code\bin\code" --wait
user.name=myUserid
user.email=myUserid#myCompany.com
credential.bitbucketauthmodes=basic
credential.microsoft.visualstudio.com.authority=BitBucket
difftool.sourcetree.cmd='' "$LOCAL" "$REMOTE"
mergetool.sourcetree.cmd=''
mergetool.sourcetree.trustexitcode=true
$ git remote -v
origin https://myUserid:myAppPassword1234567#bitbucket.org/my-workspace/my-repo.git
(fetch)
origin https://myUserid:myAppPassword1234567#bitbucket.org/my-workspace/my-repo.git
(push)
The output from the remote -v is exactly as I set it up with the $ git remote set-url command.
$ git config --list
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
credential.helper=manager-core
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true core.autocrlf=true core.fscache=true
core.symlinks=false pull.rebase=false
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master core.editor="C:\Users\my-first Wilson\AppData\Local\Programs\Microsoft VS Code\bin\code" --wait
user.name=bwilson user.email=myUserid#myCompany.com
credential.bitbucketauthmodes=basic
credential.microsoft.visualstudio.com.authority=BitBucket
difftool.sourcetree.cmd='' "$LOCAL" "$REMOTE"
mergetool.sourcetree.cmd='' mergetool.sourcetree.trustexitcode=true
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
submodule.active=.
remote.origin.url=https://myUserid:myAppPassword1234567#bitbucket.org/myWorkspace/myRepo.git
remote.origin.fetch=+refs/heads/:refs/remotes/origin/
C:\Users<username>.git-credentials
has one record in it:
https://myUserid:myAppPassword1234567#bitbucket.org
I have been coding for decades but haven't done a lot with git and bitbucket so I'm sure this is me, but I could use some help. I will answer any questions, run any tests and provide any results. Thanks!

Sourcetree not able to access GitLab

I have 2 PCs, each with SourceTree installed. On each machine, I run ssh-keygen -t rsa to generate the public & private keys and I place them in the folders:
G:/.ssh/PC1
G:/.ssh/PC2
under each folder, there are 3 files : id_rsa, id_rsa.pub, known_hosts.
I copied the content of each id_ras.pub to create a SSH key in server. On each machine, in SourceTree, I specify the "SSH Client Configuration" so that
SSH Key points to G:\.ssh\PC1\id_rsa & G:\.ssh\PC2\id_rsa
OpenSSH is used in both machine for SSH Client.
But it appears that one of the PCs is able to access GitLab properly in SourceTree, i.e., push/pull work; on the other PC, when launching SourceTree, it alerts:
'ssh-agent' failed with code -1: System.Exception:Unable to start 'C:\Users\xxx\AppData\Local\Atlassian\SourceTree\git_local\bin\ssh-agent.exe' check the git installation.
Further, I tried a new check out from GitLab to a new folder on the PC that is not working and after that it starts to work. But later, it stops working and gives the same alert.
I tried to pull from repository, and it errors:
git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin
C:\Users\xxx\AppData\Local\Atlassian\SourceTree\git_local\bin\sh.exe: *** fork: can't reserve
memory for stack 0x2E60000 - 0x3060000, Win32 error 0
0 [main] sh 11020 sync_with_child: child 7124(0x238) died before initialization with status code 0x1
13 [main] sh 11020 sync_with_child: *** child state waiting for longjmp
C:\Program Files (x86)\Atlassian\SourceTree\tools\openssh_wrapper.sh: fork: Resource temporarily unavailable
fatal: Could not read from remote repository.

How to add an SSH key to a local CircleCI build?

I'm trying to run a CircleCI test job locally by running
circleci local execute --job test
However, I'm getting this error message:
go: github.com/some/repo#v0.0.0-20180921204022-800easdf7ec: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/52f8e69c46f5a1cc77e6bf: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
I would basically like to do the equivalent of https://circleci.com/docs/2.0/add-ssh-key/ for the local CircleCI environment, but there is no way to go to Project Settings -> Checkout SSH Keys as described in that documentation. I've read the documentation at https://circleci.com/docs/2.0/local-cli/#run-a-job-in-a-container-on-your-machine but wasn't able to find a way to do this.
Any idea how I can check out code from private Github repos in the local CircleCI environment?
Have you tried adding the key to your SSH keychain?
ssh-add (location of ssh key)
This should add it to the keychain and CircleCI local should pick it up.
You can use --checkout-key argument
circleci local execute build --checkout-key id_rsa
Note: id_rsa should be in the same folder

Git clone from remote server failing in bitbucket pipelines

I'm trying to automatically deploy my app to digital ocean through bitbucket pipelines. Here are the steps my deployment is following:
connect to the remote digital ocean droplet using ssh
clone my repository by running a git clone with ssh
launch my application with docker-compose
I have successfully setup ssh access to my remote. I have also configured ssh access to my repository and can successfully execute git clone from my remote server.
However, in the pipeline, while connection to the remote server is successfull, the git clone command fails with the following error.
git#bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.
Anybody has an idea of what is going on here?
Here is my bitbucket-pipelines.yml
image: atlassian/default-image:latest
pipelines:
default:
- step:
deployment: production
script:
- cat deploy.sh | ssh $USER_NAME#$HOST
- echo "Deploy step finished"
And the deployment script deploy.sh
#!/usr/bin/env sh
git clone git#bitbucket.org:<username>/<my_repo>.git
cd my_repo
docker-compose up -d
Logs for the git clone ssh commands within the droplet and from the pipeline
Git uses the default ssh key by default.
You can overwrite the SSH command used by git, by setting the GIT_SSH_COMMAND environment variable. You can add the -i argument to use a different SSH key.
export GIT_SSH_COMMAND="ssh -i ~/.ssh/<key>"
git clone git#bitbucket.org:<username>/<my_repo>.git
From the git documentation:
GIT_SSH
GIT_SSH_COMMAND
If either of these environment variables is set then git fetch and git push will use the specified command instead of ssh when they need to connect to a remote system. The command-line parameters passed to the configured command are determined by the ssh variant. See ssh.variant option in git-config[1] for details.
$GIT_SSH_COMMAND takes precedence over $GIT_SSH, and is interpreted by the shell, which allows additional arguments to be included. $GIT_SSH on the other hand must be just the path to a program (which can be a wrapper shell script, if additional arguments are needed).
Usually it is easier to configure any desired options through your personal .ssh/config file. Please consult your ssh documentation for further details.

intellij repository clone failed: Authentication failed

versiont Control > GitHub > "Test Successufl"
IMG1
Git version : 2.18.0
SSH ececutable: Native
IMG2
BUT!!
git clone fail
IMG3
I don't know why this happens any help would be appreciated.
You are cloning via HTTP. SSH executable is not related.
Check if it works in the command line first. It could happen there is git credential.helper that somehow saved wrong credentials and git is trying to use them.
You could use SSH instead, but make sure SSH keys are registered on GitHub and, since you want to use native SSH client, the key is added to ssh-agent or does not have a passphrase, because IntelliJ is not a terminal and cannot handle interactive prompts for passphrases.
Everybody Thanks~
I resolved it in the following way.
Step 1. Create SSH Key (in Local PC)
My PC use Windows.
So, I use Git Bash.
Step 2. Register GitHub
Personal settings > SSH and GPG Keys
Nes SSH Key > XXX_rsa.pub (This contens is Created SSH Key File in Local PC)
Step 3. In intellij, Git Clone used "Use SSH" instead of "Use HTTPS".