Push to Gitlab returns fatal - ssh-keys

Using a fresh Gitlab install, generated and added SSH keys to the user account, created a new project.
From a local machine, created one (1) folder, added a readme and preformed the following from the terminal:
git init
git add README
git commit -m '1_16_2013'
git remote add origin git#192.168.1.55:root/test.git
git push -v origin master
The push asks for the git#192.168.1.55's password and returns:
Connection closed by 192.168.1.55
fatal: The remote end hung up unexpectedly
Do I need to add a shh key to my local machine?

You need to have the public and private keys (id_rsa and id_rda.pub) stored on your ~/.ssh directory of your local machine.
Otherwise, any ssh to the gitlab server will ask for a password.
You also need to use the right ssh address:
git#192.168.1.55:test.git
You shouldn't have any path in front of the name of the git repo: gitolite (used by GitLab) will detect the name of the repo and will use the right repo path.
I prefer storing this information (server name, ssh user, private key...) in a ~/.ssh/config file: see "gitolite: can connect via ssh, can't clone" as an example (or "git clone git#myserver:gitolite-admin fails").

Related

Managing ssh keys

Suppose that I have a remote server and GitLab private repository.
I do not want to add key from my server to ssh keys in GitLab account, so I make ssh key forwarding.
However, when I try to run my initial installation scripts with sudo, I cannot pull the repository because with sudo my ssh keys are not accessible on the server.
How can I handle it?
Check first, as in here, if you can allow the other user (sudo -u otheruser) to access $SSH_AUTH_SOCK file, and it's directory.
That way, you would still benefit from the original SSH tunnel: simply giving more permission to $(dirname $SSH_AUTH_SOCK) can be enough.

Breaking agent forwarding in Ansible on Vagrant

Using Ansible to provision Vagrant box, Ansible fails when cloning Git repo: Host key verification failed. fatal: Could not read from remote repository.. Oddly I can clone from Git with no issues when I SSH into the box and run git clone <GIT_URL>. Have set sudo: no in Ansible task but still fails. ssh-agent is running correctly on both host and box.
Host key verification failed.
is not related to the agent forwarding. As noted in the comments, it is related to the known_hosts file.
Before the first connection to the server (github.com), you need to manually verify it's host key, or use similar process as noted in comments, using keyscan:
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
The other (not recommended) possibility is to turn off the host key verification in the ~/.ssh/config:
Host git
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
in the home directory of the user running the git clone.

Who am I when ssh connected to another computer

In cygwin, I connect via ssh into an ec2 computer,
ssh -i xxxxxxx.pem ec2-user#ec2xxxxx.amazonaws.com
Ask who am I and get ec2-user
[ec2-user#ip-xxxxxxx]$ whoami
ec2-user
But when I run git clone with https, it asks me for my 'personal' password. So that for the user of my local computer, not the one at ec2.
Password for 'https://localuser#bitbucket.org'
What's going on? Why doesn't it use ec2-user? Isn't ssh supposed to handle only communication between my local and that remote computer?
It looks like you're using bitbucket. When you clone via BitBucket over SSH, use:
git clone git#bitbucket.org:<you>/<repository>.git
It looks like you're a) cloning over HTTPS rather than SSH, and, b) you're not specifying a username.
Before this will work, you'll need to generate an SSH key:
ssh-keygen -t rsa
And then copy the contents of ~/.ssh.id_rsa.pub to your clipboard, and then paste it into the BitBucket settings for your user account, under Account Settings -> SSH Keys. The user for SSH cloning from BitBucket will always be git, rather than your local username or ec2-user.
See here for more info.

After the upgrade to TortoiseGit v1.8.15.0 and Git v2.5.0 hosts cannot be found

I've just updated my TortoiseGit from v1.7.* to v1.8.15.0 and Git from 1.* to v2.5.0.windows.1. Now trying to perform a remote operation like pull I'm getting errors:
git.exe pull -v --progress "origin"
Unable to open connection: Host does not existfatal: Could not read
from remote repository.
Please make sure you have the correct access rights and the repository
exists.
git did not exit cleanly (exit code 1) (1747 ms # 19.08.2015 18:43:33)
I changed the SSH client setting from TortoiseGitPlink to PuTTY. It didn't work as well, but the PuTTY Error provided following information:
Unuble to open connection to github.com-foo
Host does not exist
I work with aliases and my ~/.ssh/config looks like this:
#github.com-foo account
Host github.com-foo
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_foo
#github.com-bar account
Host github.com-bar
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_bar
That worked before the upgrade and is still working in msys.
TortoiseGit seems to ignore the config. How to make TortoiseGit respect the config again?
PuTTY and TortoiseGitPlink do not respect .ssh/config (as described in e.g. Multiple GitHub Accounts & SSH Config or https://gist.github.com/jexchan/2351996). Both tools store, like Windows tools, their configuration in registry.
For using PuTTY in your scenario, please see the TortoiseGit Manual - Tips and tricks for SSH/PuTTY.
PS: .ssh/config is the config file for OpenSSH. If you want to use OpenSSH, set the ssh client to ssh.exe in TortoiseGit network settings (there is no need to use the full path to ssh.exe as it is on the %PATH%):

Permission Denied on bzr info lp:bzr

I have added my SSH Public and Private keys. But I'm still getting Permission Denied on "bzr info lp:bzr"
What am I missing? I've attached a screenshot of my Launchpad, Pageant, and the Console.
This happens when:
You told Bazaar your Launchpad username with bzr lp-login USERNAME
... but, Bazaar could not verify it (your access to USERNAME on Launchpad)
You can see your Launchpad username configuration with the command:
$ bzr config
bazaar:
[DEFAULT]
launchpad_username = the-username-you-set-with-bzr-lp-login
You can either fix your ssh key setup (see this discussion), or you can remove the launchpad_username setting with:
bzr config --remove launchpad_username --scope=bazaar
After this bzr info lp:bzr should work, unless you have other issues (for example with proxy server, network, firewalls, or others).