SSH in git behind proxy on windows 7 - windows

I am testing SSH connection for checking RSA key in git.
I am working over proxy server.
I am using window 7 and have installed msysGit-fullinstall-1.7.3.1-preview20101002.
Now in msys.exe window i have set proxy by command 'git config --global http.proxy http://host:port'
After that i have tried command 'ssh git#github.com' .
This gives me error like 'ssh: github.com: no address associated with name'
What should i do?

Setting http.proxy will not work for ssh. You need to proxy your ssh connection. See this description. To summarize:
Start git-cmd.bat and create ~/.ssh/config (notepad %home%\.ssh\config.)
ProxyCommand /bin/connect.exe -H proxy.server.name:3128 %h %p
Host github.com
User git
Port 22
Hostname github.com
IdentityFile "C:\users\username\.ssh\id_rsa"
TCPKeepAlive yes
IdentitiesOnly yes
Host ssh.github.com
User git
Port 443
Hostname ssh.github.com
IdentityFile "C:\users\username\.ssh\id_rsa"
TCPKeepAlive yes
IdentitiesOnly yes
(set the correct proxy hostname:port, and the path to id_rsa. When you use git-bash, use slashes in the path to id_rsa)
(My version of msysgit includes connect.exe, so I do not need to download and compile connect.c). A precompiled exe is also available here.
Now ssh github.com should work
Note that if you want to connect via a socks5 proxy, then change -H to -S.
ProxyCommand connect -S proxy.server.name:1080 %h %p
If you use a Linux file system, the file permission of ~/.ssh/config must be 600, but on a standard NTFS windows partition, these kind of permissions do not exist.
If your proxy requires NTLM authentication, you can use cntlm, see also this answer.

Does your proxy require a password? Then it might be that.
export http_proxy="http://<domain>\<username>:<password>#<server>:<port>"
See : How do I pull from a Git repository through an HTTP proxy? (duplicate!)

Related

How can I use ssh multiplexing on windows?

I am using remote - ssh on vscode to access a remote caen server. On WSL, I can use ssh multiplexing with the following config file:
Host *
ControlMaster auto
ControlPersist yes
ControlPath ~/.ssh/socket-%C
ServerAliveInterval 60
ServerAliveCountMax 5
However, vscode doesn't seem to let me use a file on my WSL directory for my SSH host (or am I able to do this?). On windows, when I try to use this for ssh multiplexing on a windows ssh config file, remote - ssh on vscode says it can no longer establish a connection with caen. It works without the extra control and server lines.
Host caen
HostName myhostname
User myusename
ControlMaster auto
ControlPersist yes
ControlPath C:\Users\mycomputerusername.ssh\socketfile
ServerAliveInterval 60
ServerAliveCountMax 5
Does anyone have an idea of what I am doing wrong?
I tried different controlpath filenames, accessing my wsl ssh config file with the remote - ssh on vscode, and a few other things. None worked.

How to avoid github ssh authentication problem that happens every time?

I used the vscode and install git in the system on mac. And registered the ssh key in GitHub and the device. By the way, when I git clone or git push, pull I have to register every time like this
ssh-add ~/.ssh/id_rsa even though I pull the public repository. When I work in the windows system in the past I don't get this status. I hope someone helps me to avoid this. Here id_rsa is the ssh key file for github.
Have you configured GitHub in ~/.ssh/config?
The config should include something like this:
Host github.com
Hostname github.com
User <your-github-username>
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
You can also use the AddKeysToAgent yes setting for the host, if you want the SSH Agent to remember the password of your SSH key, so you only have to enter it when using it the first time after every login.
If you want to pull from a public repository, you can avoid working with SSH keys, if you use HTTPS instead of SSH (note that this would require password authentication if you want to push).

Can't connect to Gitlab repositories with multiple keys

I have two Gitlab repositories, owned by two different users. Let's call them
personal: git#gitlab.com:user1/personal.git
work: git#gitlab.com:user2/work.git
I got two RSA keys: with key1 I can usually connect to personal repo; with key2 to work repo.
I have to push/pull from different workstations (Mac OS / Windows); on every machine, I can connect to the first or the second repo with no problems.
From a single Windows 10 workstation I need to connect to both repositories and here start the troubles.
On that workstation, I use Git Bash.
According to different guides (e.g. https://coderwall.com/p/7smjkq/multiple-ssh-keys-for-different-accounts-on-github-or-gitlab), I've setup a ~/.ssh/config file:
Host gitlab-personal
HostName gitlab.com
User git
LogLevel DEBUG3
PreferredAuthentications publickey
IdentityFile ~/.ssh/personal
#IdentitiesOnly yes
Host gitlab-work
HostName gitlab.com
User git
LogLevel DEBUG3
PreferredAuthentications publickey
IdentityFile ~/.ssh/work
#IdentitiesOnly yes
If I run
ssh -Tv git#gitlab-personal
I got:
...
Welcome to Gitlab, User1!
...
And if I run
ssh -Tv git#gitlab-work
I got:
...
Welcome to Gitlab, User2!
...
This makes me think that RSA keys are setup correctly (even in Putty / Pageant).
But if I try to clone the repositories, for example
git clone git#gitlab-personal:user1/personal.git
or
git clone git#gitlab-work:user2/work.git
..in both cases I got this response:
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.
What am I doing wrong?
Thanks to anyone who can help me.

Using git with SSH-key on Windows

I am connecting to my virtual machine with ssh like this:
ssh -i keyfile.key user#server.com
I have created a git repository on the server which I want to push to, but I do nott know how I should use the keyfile.key with git.
I am supposed to execute the command:
git push live master
But I getting the error "permission denied (publickey)", so how do I specify the key? I am on Windows 8.
You need to:
use a, ~/.ssh/config (check where %HOME% is set, since you are on Windows).
The config file would look like (replace <hostkey> by any string you want)
Host <hostkey>
HostName myserver
User user
IdentityFile C:\path\to\.ssh\keyfile.key
IdentitiesOnly yes
change your remote url to one using the config Host key
git rmeote set-url list <hostkey>:myrepo

Getting permission denied when pushing to git vps server

I installed git for windows, creating my ssh key and uploaded the public to my server.
I have this working on my Mac, trying to get it working on my windows machine now.
I did a :
chmod 700 ~/.ssh/
chmod 600 ~/.ssh/*
Here is an image of me doing a ssh -v gitserveralias
I have a config file that has the gitserveralias and port etc.
I tried clearing out the known hosts file also.
My config looks like:
Host serveralias
User xxx
Hostname 123.234.452.232
Port 22222
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive true
IdentitiesOnly yes
PreferredAuthentications publickey
Again I have my setup working fine on my Mac.
Two things to check:
Do you have "PubkeyAuthentication yes" in sshd_config on your server? Try setting it.
Is there an offending key in .ssh/known_hosts? Try removing this file.

Resources