$ ssh -i id_rsa xxx#xxx.xxx.xxx.xxx echo "hello world:w"
###########################################################
# WARNING: UNPROTECTED PRIVATE KEY FILE! #
###########################################################
Permissions for 'C:\\Users\\xxx\\id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "C:\\Users\\xxx\\id_rsa": bad permissions
Remote desktop to powershell of gitlab-runner computer, ssh can be completed, but ssh cannot be run in gitlab-runner, I want to use the command tool to fix, not the window interface
Related
I have two user accounts in Gitlab. One with axmug user and the other one with GbFlow.
When I log in using axmug user there is any key in the profile settings.
But when I log in using GbFlow user I created an SSH key file and I can watch it in the profile settings.
I use Git Bash on Windows 7 and when I type cd /Users/Invitado/.ssh and ls, I can watch three files: id_rsa, id_rsa.pub and known_hosts.
This key was generated using axmug user. Both users have different emails.
What I want to do is upload an Android project using GbFlow user. When I tried, I typed the following in Git Bash command line:
git init
git remote add origin git#gitlab.com:GbFlow/GlobalFlow.git
git add .
git commit
git push -u origin master
Everything worked except the last line: git push -u origin master. At this point I displayed the error:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have the keys created. What I am doing wrong?
Invitado means those ssh keys are created with the Guest account.
If you are not logged on as a Guest, but with your actual account, ssh will look for those keys in %HOME%\.ssh, with HOME set by default to %USERPROFILE%.
Type set us to see the value of USERPROFILE.
This key was generated using axmug user.
It does not matter with which local Windows account those keys were created. What matters is where the public id_rsa.pub was copied to: in which GitLab account. See "How to create your SSH Keys"
That would be the first reason why GitLab does not authenticate you properly: move those keys in your own %USERPROFILE%\.ssh to benefit from GbFLow identity (Assuming GbFlow profile has the public key in his/her settings).
Type ssh -T git#gitlab.com to confirm you are seen as GgFlow.
If, from the same local Windows account (Invitado or otherwise) you need to manage two different GitLab remote accounts, then see Working with non-default SSH key pair paths, and use a %USERPROFILE%\.ssh\config file.
# GbFlow
Host gbflow
Hostname gitlab.com
RSAAuthentication yes
User git
IdentityFile ~/.ssh/gbflow_rsa
# axmug
Host axmug
Hostname gitlab.com
RSAAuthentication yes
User git
IdentityFile ~/.ssh/axmug_rsa
Then use the ssh url bgflow:<user>/<repo.git> or axmug:<user>/<repo.git>
This assume you have created two different sets of ssh pairs keys.
For gbflow (renaming the existing id_rsa/id_rsa.pub files):
~/.ssh/gbflow_rsa
~/.ssh/gbflow_rsa.pub
For axmug (with ssh-keygen -t rsa -P "" -C "axmug GitLab access" -q -f ~/.ssh/axmug_rsa):
~/.ssh/axmug_rsa
~/.ssh/axmug_rsa.pub
Currently every time I start up terminal I get prompted the following:
Last login: Mon Nov 28 21:32:16 on ttys000
Agent pid 2733
Enter passphrase for /Users/my_name/.ssh/id_rsa:
Could you please guide me on how I can avoid having to enter a passphrase everytime?
You could add your passphrase to your keychain:
ssh-add -K ~/.ssh/id_rsa
Or you can add it in your ~/.ssh/config:
Host *
UseKeychain yes
You probably wrote to your ~/.bashrc lines
`eval ssh-agent`
ssh-add
or something like this. This means that it will start a new ssh-agent for every shell you open, which is certainly not what you want. The agent should start when you open your Xsession (~/.xsession), or you should check if the agent is running before running a new one:
[ -z $SSH_AUTH_SOCK ] && `eval ssh-agent` && ssh-add
You can use ssh-agent. The man-page says :
ssh-agent is a program to hold private keys used for public key
authenti‐
cation (RSA, DSA, ECDSA, Ed25519). ssh-agent is usually started in the
beginning of an X-session or a login session, and all other windows or
programs are started as clients to the ssh-agent program. Through use of
environment variables the agent can be located and automatically used for
authentication when logging in to other machines using ssh(1).
On further reading you can see :
The agent initially does not have any private keys. Keys are added
using
ssh-add(1). When executed without arguments, ssh-add(1) adds the files
~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and
~/.ssh/identity. If the identity has a passphrase, ssh-add(1) asks for
the passphrase on the terminal if it has one or from a small X11 program
if running under X11. If neither of these is the case then the authenti‐
cation will fail. It then sends the identity to the agent. Several
identities can be stored in the agent; the agent can automatically use
any of these identities. ssh-add -l displays the identities currently
held by the agent.
I'm trying to connect to a remote repository under a specific IP address.
I received the private key through email and I'm on windows using Putty. The .ppk file is in Pageant.
I also created a GIT_SSH environment variable.
After these steps my personal IP was then listed in the firewall, so I guess I was able to connect.
However, when I use git bash to connect to the server, I get the message "permission denied (public key)".
The commands I used are:
$ ssh [IP]
$ ssh [username]#IP
$ ssh -T [username]#IP
I looked up online exhaustively but with no success so far and I really need to access the repo as soon as possible.
Thanks in advance!
Obrigada :)
Two ways to go about it
Using Pageant directly inside Git Bash
This requires setting the GIT_SSH environment variable to the full path of plink.exe (which is part of the putty suite).
Also, I would highly recommend checking if plink.exe works inside GIT Bash as follows:
Full-path-to-plink.exe -v -P port sshusername#sshserver
Another thing to check is the version of Putty suite that you are using. ( I can dig out the details later but) version 0.60 had a bug due to which processes inside cmd could not access Pageant. I believe the issue was fixed in v 0.62 but feel free to use the latest (v 0.67)
Convert putty key to OpenSSH format
Another possibility is exporting the putty key to the OpenSSH format by using puttygen.exe and the using the exported key directly inside GIT Bash:
Open PuttyGen
Click Load
Load your private key
Go to Conversions->Export OpenSSH and export your private key
Copy your private key to ~/.ssh/id_dsa (or id_rsa).
Create the RFC 4716 version of the public key using ssh-keygen
ssh-keygen -e -f ~/.ssh/id_dsa > ~/.ssh/id_dsa_com.pub
Convert the RFC 4716 version of the public key to the OpenSSH format:
ssh-keygen -i -f ~/.ssh/id_dsa_com.pub > ~/.ssh/id_dsa.pub
Then you can do something like this in GIT Bash to test the ssh connectivity:
GIT_SSH=ssh
ssh -v sshusername#sshserver -i ~/.ssh/id_rsa
I have a Git repository on a Linux server and I want to clone it on Windows.
I have Git for Windows installed and I prefer using it with the command line.
I use SSH with a public key to connect to my Linux server and I have my keys generated and ready to use, but I don't know how to tell git to use the key.
When I just SSH into the box, I use this command:
ssh -i c:\path\to\private\key\id_rsa user#192.168.2.104
So, I guess I'm looking for Git's equivalent of the -i option.
Obviously, this doesn't work:
git -i c:\path\to\private\key\id_rsa clone user#192.168.2.104:/home/user/dev/myproject.git myproject
This is all on my local network.
On Windows, provided %HOME% is set to %USERPROFILE%, use a %HOME%\.ssh\config file, which can indicate, for a given entry name, the user and the path of the private key:
Host yourServer
HostName 192.168.2.104
User user
IdentityFile C:/path/to/yourPrivateKey
Test it with ssh -Tv yourServer
Then a clone would be:
git clone yourServer:/home/user/dev/myproject.git myproject
(no need to indicate user#192.168.2.104 or the path to the private key anymore: everything is in the %HOME%/.ssh/config)
That way, you can manage multiple ssh sets of public/private keys.
I have followed the instructions here: http://help.github.com/win-set-up-git/ to set up git on my windows 7 machine.
I can use "git bash" and run commands. I am prompted for my key's pass phrase and can successfully connect. E.g.:
$git push -u origin master
Enter passphrase for key '/c/Users/mbj/.ssh/id_rsa':
Everything up-to-date
Also this:
$ ssh -T git#github.com
Enter passphrase for key '/c/Users/mbj/.ssh/id_rsa':
Hi markbrenigjones! You've successfully authenticated, but GitHub does not provi
de shell access.
$ which ssh
/bin/ssh
However, when I open a regular windows command prompt and run the same command, I get this:
C:\util\meta_vimrc>git push
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Also this:
C:\util\meta_vimrc>ssh -T git#github.com
Permission denied (publickey).
C:\util\meta_vimrc>which ssh
C:\Program Files (x86)\Git\bin\ssh.exe
How do I get this working from the non "git bash" prompt?
Perhaps the program has no idea where your HOME directory is when running from the Windows cmd.exe interpreter. For this to work, the ssh configuration directory with your key has to be found, namely /c/Users/mbj/.ssh.
Set this by running:
set HOME=C:\Users\mbj\
What works for me is to run PuTTY's Pageant.exe and add your private key to it. Then plink.exe knows where to find the key no matter what.