Generating SSH keys between git local and remote repository over proxy - linux

I am using CentOS7.
I have tried to set connection between my local git repository and remote git repository on github.com. But my local repository is at work and it is behind the proxy.
I have found a lot of answers on stackoverflow about this problem. Maybe I am not so attentive and so on...but I haven't resolved my problem yet.
My steps were:
Creation of repository at github.com
Generating SSH keys using this tutorial https://help.github.com/articles/generating-ssh-keys/
But on "Step 5: Test the connection" in link-tutorial after using command ssh -T git#github.com
I was a little bit confused.
Connection did not work and I got this error:
ssh: Could not resolve hostname github.com: Name or service not known
Blockquote
At first I tried to set proxy in git config file:
git config --global http.proxy http://http://192.168.32.2:3128 But the result was the same I couldn't connect to my remote repository.
Next step was to set address of github.com in /etc/hosts as : 192.30.252.0 github.com
Address for github.com I took from here https://help.github.com/articles/what-ip-addresses-does-github-use-that-i-should-whitelist/.
After using command ssh -T git#github.com everything just hang up.
Despite the fact that connection through ssh did not work I tried to clone repository from my remote github account to my local account at work: git clone https://github.com/Nit84/hello-world.git. And everything copied as it should be and without any password.
At this point I just got stack. And I haven't the faintest idea what to do further.
Here is a list of my configurations using git config --list:
[root#localhost hello-world]# git config --list
user.name=Nit84
user.email=blob#gmail.com
core.editor=vim
http.proxy=http://192.168.32.2:3128
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=ssh://git#github.com/Nit84/hello-world.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
and here is the verbose mode of ssh -vT git#github.com:
[root#localhost hello-world]# ssh -vT github.com
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
ssh: Could not resolve hostname github.com: Name or service not known
Is there any way to resolve my problem with connection between git local and remote repository using ssh-keys over proxy? Simply saying I want my command ssh -T git#github.com works as it is described in genereting ssh keys

Related

gnutls_handshake() failed: Handshake failed GIT

Everything was working fine but suddenly I am getting the error:
fatal: unable to access
'https://username#bitbucket.org/name/repo_name.git/':
gnutls_handshake() failed: Handshake failed
I am getting this on my computer as well as an EC2 instance. When I tried on another computer then it is working fine there.
I have tried many solutions from Stackoverflow and from other forums. but nothing worked!
On the computer, os is Linux mint 17 and on EC2 instance, Ubuntu 14.04.6 LTS.
What can be the issue and what should I do to fix this issue?
Ran into the same issue on a server with Ubuntu 14.04, and found that on Aug 24, 2020 bitbucket.org changed to no longer allow old ciphers, see https://bitbucket.org/blog/update-to-supported-cipher-suites-in-bitbucket-cloud
This affects https:// connections to bitbucket, but does not affect ssh connections, so the quickest solution for me was to add an ssh key to bitbucket, and then change the remote from https to ssh.
The steps to change the remote I found from here, and they are essentially:
# Find the current remote
git remote -v
origin https://user#bitbucket.org/reponame.git (fetch)
origin https://user#bitbucket.org/reponame.git (push)
# Change the remote to ssh
git remote set-url origin git#bitbucket.org:reponame.git
# Check the remote again to make sure it changed
git remote -v
There is more discussion about the issue on the Atlassian forums at https://community.atlassian.com/t5/Bitbucket-questions/fatal-unable-to-access-https-bitbucket-org-gnutls-handshake/qaq-p/1468075
The quickest solution is to use SSH instead of HTTPS. I tried other ways to fix the issue but it was not working.
The following are steps to replace HTTPS from SSH:
Generate ssh key using ssh-keygen on the server.
Copy the public key from the generated id_rsa.pub file from step 1 and add it at following links depending on the repository host -
Bitbucket - https://bitbucket.org/account/settings/ssh-keys/
Github - https://github.com/settings/ssh/new
Gitlab - https://gitlab.com/profile/keys
Now run the following command to test authentication from the server command line terminal
Bitbucket
ssh -T git#bitbucket.org
Github
ssh -T git#github.com
Gitlab
ssh -T git#gitlab.com
Go to the repo directory and open .git/config file using emac or vi or nano
Replace remote "origin" URL (which starts with https) with the following -
For Bitbucket - git#bitbucket.org:<username>/<repo>.git
For Github - git#github.com:<username>/<repo>.git
For Gitlab - git#gitlab.com:<username>/<repo>.git
sudo bash
mkdir upgrade
cd upgrade
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
tar xpvfz openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./Configure
make ; make install
cd ..
wget https://curl.haxx.se/download/curl-7.72.0.tar.gz
tar xpvfz curl-7.72.0.tar.gz
cd curl.7.72.0
./configure --with-ssl=/usr/local/ssl
make ; make install
cd ..
git clone https://github.com/git/git
cd git
vi Makefile, change prefix= line to /usr instead of home
make ; make install

Unable to connect to GIT repository from one of the linux server

When I try to clone the repository in Linux machine I am facing the below issue
-bash-4.1$ git clone
ssh://xxxxx#alm.oraclecorp.com:2222/epm_pbcs_15318/pbcs.git
Initialized empty Git repository in /home/xxxx/testgit/pbcs/.git/
Permission denied (keyboard-interactive,publickey).
fatal: The remote end hung up unexpectedly
Note:- I have added public ssh key in the repository
I have generated a key in my Linux machine using
ssh-keygen -t rsa -C "email#gmail.com"
and later on, copied the public key to alm where the GIT is hosted.
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwVM4haHIEOk6P7+h4xEDyZBrGjSLx53jNFE1AqMNWnPKWwxpGX5w4l/B0WJpP7G9gLJaZPw9loSEDDr3mGx5bRi3D8k6EFgFMpctALJlKTHFW1x47A1Z+0h2GZUvL5WZj1ZXicvpbHRxX5B+FB8s+b2d3uvwVVl26lIK3f6K2iUiRePlUH/1TPBTk/kzxvDBZQCRQKxM4Zb13S7b9WJcxt85g3+jCIebDbAaswUmIeWicM+BREmcP75ZV6ZEF1cBB54TvMrygsTzJacQS6/IsobOaZpWM7iVXTnEGjFh8iKCA5VacMMEt+QR8kc/CGOm1ujcNFbK6hikp2CpSOo4wQ== email#gmail.co
Please help me if there is any way to fix it
I think your problem is that you are not using your private key to connect to that repository.
The easiest way to do it is by adding the following lines to either ~/.ssh/config or /etc/ssh/ssh_config, please be careful and add the lines at the beggining of the file, * configuration must be at the end of the /etc/ssh/ssh_config (if you use this file for configuration):
Host alm.oraclecorp.com
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
IdentityFile YOUR_PRIVATE_KEY_LOCATION
Port 2222
User YOUR_USER
REMEMBER TO EDIT YOUR_PRIVATE_KEY_LOCATION AND YOUR_USER with your data
Let me know if this worked.
BR

Cannot push to my github private repository

As I'm learning git, I have set up a private repository on GitHub. I have created ssh key and store it to my GitHub account and edited .ssh/config file on my local Linux machine:
## github
Host github.com
User git
HostName github.com
IdentityFile ~/.ssh/github.key
I can successfully connect to my GitHub account:
$ ssh -T github
Hi <UserName>! You've successfully authenticated, but GitHub does not provide shell access.
I have initialized a git repository on my local machine, set up user and added a remote repository:
$ git init
$ git config user.name "UserName"
$ git config user.email "UserEmail"
$ git remote add origin ssh://github:<UserName?/<repositoryName>.git
I have created a README.md file, added it to git and commited it:
$ git add README.md
$ git commit -m "First commit."
Now everytime I try to push, I get this error:
$ git push origin master
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Cloning the repository works, however that is the only thing I can do.
Why can't I push to my private repository? What am I doing wrong?
Try instead the scp syntax, to make sure your ~/.ssh/config file is used:
git remote set-url origin github:<username>/<repo>
Then try and push again.
Git itself uses an OpenSSH version (at least the one packages with Git for Windows)
> ssh -V
OpenSSH_7.5p1, OpenSSL 1.0.2k 26 Jan 2017
As explained in "Why doesn't the ssh command follow RFC on URI?", there is a difference between:
ssh://[user#]host.xz[:port]/path/to/repo.git
vs.
user#host.xz:/path/to/repo.git
Only the latter syntax user#host.xz: uses the ssh config file.
When SSH was originally developed, it was developed as a more secure, drop-in replacement for the earlier RSH/rlogin suite of tools.
See "History of the SSH protocol".
OpenSSH (1999) predates URI (finalized in RFC 3986, published in January 2005)
If the host portion was allowed to be on the form host:port, this would create a potential ambiguity: does jdoe#host.example.com:2222 refer to ~jdoe/2222 on host.example.com when connecting on the standard port, or does it refer to no file at all (or worse, ~jdoe) on host.example.com when connecting over port 2222?

Cannot clone repository: FATAL: R any gitolite-admin gitolite DENIED by fallthru

I'm setting up gitolite for first time. I'm following this instructions.
When I ssh, it looks fine:
$ ssh -p 2222 gitolite#debian
PTY allocation request failed on channel 0
hello gitolite, this is gitolite#debian running gitolite3 v3.5.3.1-1-gf8776f5 on git 1.7.2.5
R W gitolite-admin
R W testing
Connection to debian closed.
But when trying to clone, it gives me the following error:
$ git clone ssh://gitolite#debian:2222/home/gitolite/repositories/gitolite-admin.git
Cloning into 'gitolite-admin'...
FATAL: R any home/gitolite/repositories/gitolite-admin gitolite DENIED by fallthru
(or you mis-spelled the reponame)
fatal: The remote end hung up unexpectedly
I'm trying to clone from yasin#vonneumann account. I uploaded this user RSA public key to debian server, renamed it to gitolite.pub and ran gitolite setup -pk gitolite.pub with no messages or errors. Then at yasin#vonneumann host I created a file at ~/.ssh/config with the following content:
host debian
user gitolite
hostname debian
identityfile ~/.ssh/gitolite
(I also copied id_rsa as gitolite at vonneumann)
I found this question to be similar, but the answers did not work for me.
Any help appreciated, thanks.
If you have a ~/.ssh/config file, you need to use the scp-like syntax for your ssh url:
git clone debian:gitolite-admin.git
With a config like:
host debian
user gitolite
hostname debian
identityfile ~/.ssh/gitolite
port 2222
And you are not supposed to specify the full path of the repo.

Gitolite Error: gitolite-admin not a repo

Quick Note: Before anyone points it out, I did originally post this on Server Fault, but after doing so I realized this site may be more appropriate. Sorry for the "double post".
I had installed gitolite about 6 months ago and all of a sudden I started getting this error:
fatal: 'gitolite-admin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
I have read a lot of other topics on this and done everything they suggested from removing the auth keys and adding a config file in ~/.ssh. Mine is below:
host myhost
user git
hostname myhost
port 22
identityfile ~/.ssh/id_rsa
host mygit
user git
hostname myhost
port 22
identityfile ~/.ssh/obto
Sadly, though, I'm still getting the fatal error. Does anyone have any ideas?
I solved this issue by doing what you just said: I create a file called config in my client machine:
vim ~/.ssh/config
Host 192.168.0.14
user git
hostname 192.168.0.14
port 22
identityfile ~/.ssh/userX
The userX file is your public file (userX.pub). Then I cloned the gitolite-admin repository in my client machine by doing:
**git clone 192.168.0.14:gitolite-admin**
Cloning into 'gitolite-admin'... Enter passphrase for key
'/home/userX':
Now you should enter the password of your key. And that's it. I hope this helps.
Regards.

Resources