I run git push -u origin master
It tells me that "Permission denied (public key) fatal: The remote end hung up unexpectedly"
Then I looked up on the internet and found that I had to generate an ssh key for my account on GitHub. However, upon doing so, when I tried to do ssh-keygen -t rsa "email#youremail.com" it simply said ssh-keygen is not recognized. I tried doing mkdir C:\ssh but that didn't work. If it helps I'm using Ruby Rails and I'm on a Windows computer. Could anyone help me?
2012:
ssh-keygen.exe is part of msysgit:
C:\path\to\msysgit1.7.11\bin\ssh-keygen.exe
if your %PATH% includes C:\path\to\msysgit1.7.11\bin\, you will have ssh-keygen.
Update 2015:
ssh-keygen.exe is part of Git For Windows, whose releases include PortableGit-2.4.3.1-2nd-release-candidate-64-bit.7z
c:\path\to\PortableGit-2.4.3.1-2nd-release-candidate-64-bit\usr\bin\ssh-keygen.exe
That means the %PATH% must include c:\path\to\PortableGit-2.4.3.1-2nd-release-candidate-64-bit\usr\bin (without the ssh-keygen.exe)
As I explained before, Git for Windows will soon phase out msysgit.
I detailed in "Why is it that if you download Git 2.0 from the net, you always get a 1.9.4 installer package?" how this new version is based on the more recent msys2 project.
I just had this issue and thought I'd share what I thought was an easier way around this.
Open git-bash and run the same command with the addition of -C since you're commenting in your email address: ssh-keygen -t rsa -C "email#youremail.com" command. That's it.
git-bash should have been installed when you installed git. If you can't find it you can check C:\Program Files\Git\Git Bash
The first time I did this it failed to create the .ssh folder for me so I had to open a standard Command Prompt and mkdir C:\Users\yourusername\.ssh
I followed below in windows (With Git for Windows installed)
Run "Git Gui" (Start --> Git --> Git Gui)
Click Help and then Show SSH Key
Click Generate Key if you do not have one already
Note:- this creates the key files under your personal profile folder C:\Users\YourUserID\.ssh\
No need to add anything to environmental variables! Just open up git bash and perform command the ssh-keygen in there.
Link to download git bash here
I found an easy solution to fix this :
In the command prompt, go to your git\bin directory,
and then execute your commands from here
If you have installed Git, and is installed at C:\Program Files, follow as below
Go to "C:\Program Files\Git"
Run git-bash.exe, this opens a new window
In the new bash window, run "ssh-keygen -t rsa -C""
It prompts for file in which to save key, dont input any value - just press enter
Same for passphrase (twice), just press enter
id_rsa and id_rsa.pub will be generated in your home folder under .ssh
Just go to heroku.bat and add:
#SET PATH="D:\Program Files (x86)\Git\bin";%PATH% after #SET PATH=%HEROKU_RUBY%;%PATH%
in my case it's in D:\Program Files (x86)\Git\bin, change it to the path you've installed Git to. (i just left it with my path so it will be clearer on how to write this)
I think you can add the location of the file ssh-keygen.exe in the PATH environment variable. Follow the steps: Go to My Computer->Right click->Properties->Advanced System Settings->Click Environmental Variables. Now click PATH and then click EDIT. In the variable value field, go to the end and append ';C:\path\to\msysgit1.7.11\bin\ssh-keygen.exe' (without quotes)
don't do anything just type in your command prompt
C:\> sh
then you got like this
sh-4.4$
# type here
ssh-4.4$ ssh-keygen -t rsa -b 4096 -C "example#example.com"
this should must work.
For windows you can add this:
SET PATH="C:\Program Files\Git\usr\bin";%PATH%
You probably should check this. Windows doesn't have that command built in.
I got it fixed by just adding ssh-keygen to my environment variables.
for those who does not choose BASH HERE option. type sh in cmd then they should have ssh-keygen.exe accessible
In my machine, ssh-keygen was available from powershell.
Related
I'm having trouble trying to checkout a repo using the following syntax on a Windows 7 workstation with TortoiseSvn:
svn co svn+ssh://user#ip/repo .
What I've done to test this issue:
Modified the network settings of TortoiseSvn to point to ..\TortoisePlink.exe
Successfully established an ssh connection to the target machine with no issues
Successfully checked out repos from workstations running Ubuntu with OpenSsh
When I try to do the above syntax from the command line on the Windows 7 workstation I get the error:
svn: E720087: Unable to connect to a repository at URL 'svn+ssh:///user#ip/repo'
svn: E720087: Can't create tunnel:The parameter is incorrect.
Interestingly, if I use the tortoise gui to browse to the repo I can successfully open and check out the repo. But I need to do it from the command line for scripting purposes.
Any suggestions?
For svn+ssh to work with Tortoise, make sure %SVN_SSH% is set to your ssh client (probably plink.exe from Tortoise or Putty) and the path must be written either with forward slashes / or with escaped backslashes \\.
Try to set %SVN_SSH% with the absolute path of plink while escaping the backslashes, something like C:\\Program Files\\TortoiseSVN\\bin\\TortoisePlink.exe instead of ..\TortoisePlink.exe
Check that the path to TortoisePlink is not corrupted in your Tortoise SVN config...
Start > Program Files > Tortoise SVN > Settings
Under General Settings, "Subversion configuration file:" click "Edit"
This will open the config file in Notepad
Scroll down to the [tunnels] section and check the value for ssh which should be uncommented, use double slashes etc - I had problems as there seemed to be a Unicode control code at the beginning of the path.
### On Windows, if you are specifying a full path to a command,
### use a forward slash (/) or a paired backslash (\\) as the
### path separator. A single backslash will be treated as an
### escape for the following character.
ssh = C\:\\Program Files\\TortoiseSVN\\bin\\TortoisePlink.exe
Connect to server, using Plink, by hand. Define needed and correct (for you) startup-options of plink
Add this line (use tortoiseplink as windowless-plink) into %APPDATA%config file, [tunnels] section
It also turns out the the line in the Tunnels section of the config file is case sensitive.
For example:
sh = $SVN_SSH "C:/path/putty/plink.exe" -2 -C -i "C:/path/username/serversvn.ppk"
might work
and
sh = $SVN_SSH "C:/path/PuTTY/plink.exe" -2 -C -i "C:/path/username/serversvn.ppk"
won't work
I had a similar, but slightly different issue.
I tried connecting to our SSH+SVN server through Pycharm and it hung. Tried the regular way through windows right click, tortoiseSVN and got this same "Can't create tunnel" issue.
I believe this issue was created because I tried to connect to my repo via pycharm, which automatically created a tunnel line in the tortoise SVN config file.
I followed Kevin Sadler's answer, but just commented out the ssh line, and it was back to normal. Checkouts and commits were working again.
Kevin's answer:
Check that the path to TortoisePlink is not corrupted in your Tortoise SVN config...
Start > Program Files > Tortoise SVN > Settings
Under General Settings, "Subversion configuration file:" click "Edit"
This will open the config file in Notepad
Scroll down to the [tunnels] sections. Comment out the SSH line.
I feel like I am missing some fundamental concept as to how the .ssh directory works in windows. I have had no issues when working in OSX/Linux like I am having now. My end goal is simply to move my existing ssh key into the default ~/.ssh directory, and update the config if I so choose (you know, normal ssh key related tasks).
However, any time I have tried to move my existing SSH key over to the ~/.ssh directory, or open it, or even create a config file I just get the following error (in either gitbash, puttygen, etc...):
Puttygen (saving the key to disk):
Overwrite existing file C:\Users\me\.ssh?
or in gitbash (attempting to do anything, including just create the config file):
touch: creating `/c/Users/me/.ssh/config': No such file or directory
cd ~/.ssh
sh.exe": cd: /c/Users/me/.ssh: Not a directory
What am I missing/not understanding?
Kind Regards,
u353
This answer for Windows environment:
At the beginning, Windows didn't have .ssh folder.
Create an ssh key file pair like this (ssh-keygen is nowadays a native Windows command, that comes with Windows 10+11):
ssh-keygen -t rsa -b 4096 -C "your_email#example.com" (must run your terminal as administrator).
Your is_rsa and id_rsa.pub files will be placed under C:\Users\your_username\
So, you need to create the folder C:\Users\your_username\.ssh then copy your ssh files (the extensionless private key and the public key ending in .pub) to there.
You also have to create file C:\Users\your_username\.ssh\config and edit it for the first time.
Next ssh will be placed in the .ssh folder automatically.
Note: ~/ under Linux is the equivalent of C:\Users\your_username\ on Windows
I have created and regularly use a ".ssh" directory on Windows 7; as mentioned in the above comments, Windows Explorer doesn't support them, or more specifically, the error-checking in Windows Explorer does not allow you to give a file name that starts with a period. That same restriction does not exist in the command prompt or powershell.
Also, as mentioned above, it appears you have a file called ".ssh" in your home directory, which must be removed before you can create a folder named ".ssh".
Once such a folder exists, you can open it and change/create files in it using Windows Explorer; it just won't let you name a folder/file ".ssh" directly.
Gitbash should directly allow you to run "rm .ssh" and "mkdir .ssh", at which point everything else should work.
It is quite possible to add a . in the beginning of a directories name using File Explorer, it can be easily done by adding a . at the end of the directory name as well. For example:
To create a directory named .shh, just add the name as .ssh. and it will be created without any error.
And as #Bryson mentioned, this can be done from the cli as well, without appending a . at the end.
Coming to this in 2018, given that on Windows 10 you have the Optional Feature OpenSSH client installed it appears that on Windows a .ssh folder is created for you under C:\Users\<your_username>\.ssh
This is a feature that allows you to use PowerShell to SSH into remote hosts, and seems to be pretty similar in usage to the Linux/Unix equivalent. It was already installed for me when I setup my computer, but you can read the following for how to verify it's installed or install it:
You can check if it's installed by going to Settings -> Manage Optional Features, and then checking if you see OpenSSH in the list. If it is then your .ssh folder is probably in your home directory C:\Users\<your_username>\.ssh. If you need to install it then click "Add a feature", locate OpenSSH Client, click it and click install to install it.
Use git bash on windows
go to home directory as
$ cd
then to check .ssh folder on home directory use
$ ls -A
you will be able to see a ./ssh folder there
$ cd ./ssh
$ ls
you will be able to see the config files if exists
To transfer any key-pair or any files to this folder use below command
First to that directory in which you already have key-pair
$ cp name_of_key-pair_file.pem ~/.ssh/
First of all, if you want to generate SSH files, all you need to do is run this command:
ssh-keygen
Once you did, .ssh folder will be generated in this path:
C:\Users\your_username\
For checking what files are in .ssh folder you can easily run this command:
ls ~/.ssh
with this above command, you can see all your ssh files which would be like this:
id_rsa id-rsa.pub
Please note that:
id_rsa : It's a private file and
id-rsa.pub : It's a public file
so, if you like to see inside of that file or whatever you like just type this command :
cat ~/.ssh/id_rsa.pub
To solve this problem I used git batsh console
This isn't supported as Windows doesn't recognize dot files as directories.
I'm having trouble trying to checkout a repo using the following syntax on a Windows 7 workstation with TortoiseSvn:
svn co svn+ssh://user#ip/repo .
What I've done to test this issue:
Modified the network settings of TortoiseSvn to point to ..\TortoisePlink.exe
Successfully established an ssh connection to the target machine with no issues
Successfully checked out repos from workstations running Ubuntu with OpenSsh
When I try to do the above syntax from the command line on the Windows 7 workstation I get the error:
svn: E720087: Unable to connect to a repository at URL 'svn+ssh:///user#ip/repo'
svn: E720087: Can't create tunnel:The parameter is incorrect.
Interestingly, if I use the tortoise gui to browse to the repo I can successfully open and check out the repo. But I need to do it from the command line for scripting purposes.
Any suggestions?
For svn+ssh to work with Tortoise, make sure %SVN_SSH% is set to your ssh client (probably plink.exe from Tortoise or Putty) and the path must be written either with forward slashes / or with escaped backslashes \\.
Try to set %SVN_SSH% with the absolute path of plink while escaping the backslashes, something like C:\\Program Files\\TortoiseSVN\\bin\\TortoisePlink.exe instead of ..\TortoisePlink.exe
Check that the path to TortoisePlink is not corrupted in your Tortoise SVN config...
Start > Program Files > Tortoise SVN > Settings
Under General Settings, "Subversion configuration file:" click "Edit"
This will open the config file in Notepad
Scroll down to the [tunnels] section and check the value for ssh which should be uncommented, use double slashes etc - I had problems as there seemed to be a Unicode control code at the beginning of the path.
### On Windows, if you are specifying a full path to a command,
### use a forward slash (/) or a paired backslash (\\) as the
### path separator. A single backslash will be treated as an
### escape for the following character.
ssh = C\:\\Program Files\\TortoiseSVN\\bin\\TortoisePlink.exe
Connect to server, using Plink, by hand. Define needed and correct (for you) startup-options of plink
Add this line (use tortoiseplink as windowless-plink) into %APPDATA%config file, [tunnels] section
It also turns out the the line in the Tunnels section of the config file is case sensitive.
For example:
sh = $SVN_SSH "C:/path/putty/plink.exe" -2 -C -i "C:/path/username/serversvn.ppk"
might work
and
sh = $SVN_SSH "C:/path/PuTTY/plink.exe" -2 -C -i "C:/path/username/serversvn.ppk"
won't work
I had a similar, but slightly different issue.
I tried connecting to our SSH+SVN server through Pycharm and it hung. Tried the regular way through windows right click, tortoiseSVN and got this same "Can't create tunnel" issue.
I believe this issue was created because I tried to connect to my repo via pycharm, which automatically created a tunnel line in the tortoise SVN config file.
I followed Kevin Sadler's answer, but just commented out the ssh line, and it was back to normal. Checkouts and commits were working again.
Kevin's answer:
Check that the path to TortoisePlink is not corrupted in your Tortoise SVN config...
Start > Program Files > Tortoise SVN > Settings
Under General Settings, "Subversion configuration file:" click "Edit"
This will open the config file in Notepad
Scroll down to the [tunnels] sections. Comment out the SSH line.
So I just moved from Ubuntu to Windows (read forced to move, thanks to compatibility issues) and am using Git Bash to pull in my files. I've noticed something extremely strange.
Git Bash is installed in C:\Program Files (x86)\Git\, and when I first run the Git Bash program, the default location is this. Normal right? Right.
But here's the weird part..
When I run the command mkdir srv in the Git Bash command line, I can see it in the Bash window - but I can't see it in Windows Explorer?! What the heck. Same thing happens with files created using vi in the CLI. Invisible in Windows Explorer. (Yes, I have enabled the Show hidden files option in Explorer, so it's not that).
Here are some snapshots (no, I'm not blind - nor am I insane). Help?
You might not be able to see the folder because of missing privileges. Try running your explorer as Administrator and look again.
The proposed solutions above didn't help me. However, I copied the hidden directories to another place via git bash. Then I copied them once again via windows explorer to the original place. Now they've become visible. I created those invisible folders via git bash with git clone command before.
I had similar issue, but with file attributes, not with missing privileges.
In cmd under C:\Program Files (x86)\Git\ run command attrib
attrib *
You will know if srv folder has System or Hidden file attribute.
If you would like to view it in cmd then use dir /a:s
I've went through the excellent guide provided by Tim Davis which is about configuring Git to work with SSH under Windows in order to produce a Git Server in order to have a main place for my DVCS.
I am in the process of creating a clone for my project. I’ve went through all the steps till this point, but I keep getting this from TortoiseGit:
git.exe clone -v “ssh://Administrator#127.0.0.1:22/SSH/Home/administrator/myapp.git” “E:\GitTest\myapp”
bash: Administrator#127.0.0.1: command not found
Initialized empty Git repository in E:/GitTest/myapp/.git/
fatal: The remote end hung up unexpectedly
Success
and nothing gets cloned.
BTW: The TortoisePLink comes up just before this message appears and asks me: “login as:” ( I thought that this info is given in the command, i.e: Administrator#blahblah.
My home variable is set to the correct place:
From a Git Bash shell:
echo $HOME
/c/SSH/home/Administrator
I’ve also tried using Putty’s plink instead of TortoisePLink (in both Git’s and TortoiseGit’s installation). This time the error was narrowed down to:
git.exe clone -v “ssh://Administrator#127.0.0.1:22/c:/SSH/Home/administrator/myapp.git” “E:\GitTest\myapp”
Initialized empty Git repository in E:/GitTest/myapp/.git/
fatal: The remote end hung up unexpectedly
I fought with this problem for a few hours before stumbling on the obvious answer. The problem I had was I was using different ssh implementations between when I generated my keys and when I used git.
I used ssh-keygen from the command prompt to generate my keys and but when I tried "git clone ssh://..." I got the same results as you, a prompt for the password and the message "fatal: The remote end hung up unexpectedly".
Determine which ssh windows is using by executing the Windows "where" command.
C:\where ssh
C:\Program Files (x86)\Git\bin\ssh.exe
The second line tells you which exact program will be executed.
Next you need to determine which ssh that git is using. Find this by:
C:\set GIT_SSH
GIT_SSH=C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe
And now you see the problem.
To correct this simply execute:
C:\set GIT_SSH=C:\Program Files (x86)\Git\bin\ssh.exe
To check if changes are applied:
C:\set GIT_SSH
GIT_SSH=C:\Program Files (x86)\Git\bin\ssh.exe
Now git will be able to use the keys that you generated earlier.
This fix is so far only for the current window. To fix it completely you need to change your environment variable.
Open Windows explorer
Right-click Computer and select Properties
Click Advanced System Settings link on the left
Click the Environment Variables... button
In the system variables section select the GIT_SSH variable and press the Edit... button
Update the variable value.
Press OK to close all windows
Now any future command windows you open will have the correct settings.
Since this keeps coming up in search results for making git and github work with SSH on Windows (and because I didn't need anything from the guides above), I'm adding the following, simple solution.
(Microsoft says they are working on adding SSH to Visual Studio, and GitHub for Windows still doesn't support SSH...)
1. I installed "git for Windows" (which includes ssh and a bash shell)
https://git-scm.com/download/win
2. From the included bash shell (which, for me, was installed at: C:\Program Files\Git\git-bash.exe)
cd to the root level of where you want your repo saved (something like: C:\code\github\), and
Type:
eval $(ssh-agent -s) && ssh-add "C:\Users\YOURNAMEHERE\.ssh\github_rsa"
3. Type: (the SSH link from the repo)
git clone git#github.com:RepoName/Project.git
you are using a smart quote “ instead of " here:
git.exe clone -v “ssh://
^^^
Make sure you use the plain-old-double-quote.
I've found my ssh.exe in C:/Program Files/Git/usr/bin directory.
If Git for windows is installed, run Git Bash shell:
bash
You can run ssh from within Bash shell (Bash is aware of the path of ssh)
To know the exact path of ssh, run "where" command in Bash shell:
$ where ssh
you get:
c:\Program Files\Git\usr\bin\ssh.exe
I was trying to solve my issue with some of the answers above and for some reason it didn't work. I did switch to use the git extensions and this are the steps I did follow.
I went to Tools -> Settings -> SSH -> Other ssh client
Set this value to C:\Program Files\Git\usr\bin\ssh.exe
Apply
I guess that this steps are just the same explained above. The only difference is that I used the Git Extensions User Interface instead of the terminal. Hope this help.
When I typed where ssh it showed me multipe ssh.exe
user#pc MINGW64 /c/dev/
$ where ssh
C:\Users\user\AppData\Local\Programs\Git\usr\bin\ssh.exe
C:\Windows\System32\OpenSSH\ssh.exe
Deleting / moving these exe helped:
# copy from
# C:\Users\user\AppData\Local\Programs\Git\usr\bin
# to something like
# C:\Users\user\AppData\Local\Programs\Git\usr\bin\backup-ssh
ssh-agent.exe
ssh.exe
ssh-add.exe
This solved the issue for me.