might be a dumb question.... but where do we add the ssh keys of the workstation to the git server both being purely on windows 2012 R2... ..Without the use of github
i had created a remote in the git server repo as
git remote add origin edscs-npe\bzky7x#IP:/c/temp/repo.git
In the workstation i am trying to clone the link as ..
$ git clone edscs-npe\bzky7x#IP:/c/temp/repo.git
Cloning into 'repo'...
ssh: connect to host "IP" port 22: Connection refused
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Now the problem I think here is on the authentication between both the workstation and the git server... where do I add the ssh keys of the workstation to the git server both being windows machine...
Much help would be appreciated
Now the problem i think here is on the authentication between both the workstation and the git server...
To test this, just ssh from the workstation to the server. If it prompts you for a password and you are able to type it in and connect, then yes, you need to set up your ssh keys. If not, then there is more setup you need to do on the server end that is outside the scope of this question.
First, on your workstation you need to set up your public/private keys. You can do this with a command like:
ssh-keygen -t rsa
After hitting enter to accept the defaults, you should get some files in your ~/.ssh folder.
Now you need to add your public key to the authorized_keys on the server account you use for your git operations (You will need to enter a password for this operation)
cat ~/.ssh/id_rsa.pub | ssh user#server 'cat >> .ssh/authorized_keys'
You should be able to both interactively ssh into the server and use git to clone from the server.
Related
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).
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.
Trying to use Envoy via Vagrant (Homestead) to deploy to a server on EC2 that I would normally use a .PEM file when I SSH into it.
When using: #servers(['web' => 'ec2-user#myserver.com']) in my Envoy.blade.php
I get: Permission denied (publickey).
Any help would be huge!
Answer is here: https://stackoverflow.com/a/32088143/13346162
You need to pass the -A (as per the man page it - Enables forwarding of the authentication agent connection. This can also be specified on a per-host basis in a configuration file) in you ssh string.
You will also need add your ssh key for agent forwarding (on the machine which can access the git remote which I assume be your localhost)
ssh-add -K ~/.ssh/your_private_key
Something like this
#servers(['web' => '-A user#domain.com'])
#task('deploy')
cd /path/to/site
git status
#endtask
Git remote commands should now work.
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
I have set up my ssh key in ~/.ssh and tested it on another PC (working)
ssh to git#bitbucket.org OK
ssh to bitbucket.org FAIL
git clone form git#bitbucket.org:account/gmc.git FAIL
Any idea what is happening in this case and I am not able to git clone ?
user#pc //server/users$/user
$ ssh git#bitbucket.org
Enter passphrase for key '/c/Users/user/.ssh/id_rsa':
logged in as thedev.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
Connection to bitbucket.org closed.
user#pc //server/users$/user
$ ssh bitbucket.org
Permission denied (publickey).
user#pc //server/users$/user
$ git clone git#bitbucket.org:account/gmc.git
Cloning into 'gmc'...
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40
Connection abandoned.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
know_hosts file
bitbucket.org,131.103.20.167 ssh-rsa abc...==
Seems like the problem was conflict between Open SSH and PLINK.exe (used by putty)
Details here:
Git server's host key not cached in registry - GitHub.com
Got it working by changing the GIT_SSH env var to /usr/bin/ssh.exe and now using openssh.