How to generate key on git bash - windows

I use this command on git bash
`$ ssh-keygen -t rsa -C "eu.json#gmail.com"`
After that, these line of text show.
`'Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/jayson/.ssh/id_rsa):'.`
There is no other line of text shown and stuck there, I wait for long time and still nothing happen not like the video that i follow, I need to use it on laravel homestead.

You are supposed to click ENTER (twice if you don't want a passphrase associated to the private key).
That will validate the file to be saved.
/c/Users/jayson/.ssh/id_rsa (private key)
/c/Users/jayson/.ssh/id_rsa.pub (public key)

Related

How to avoid add ssh key everytime when push or pull the code

I generated the ssh pub key and private key and register pub key to my github.
And add the private key by using this
$ eval $(ssh-agent -s)
$ ssh-add ~/.ssh/id_rsa
But I have to put this command everytime when I push or pull the code.
I hope to avoid this.
You should not have to write those commands everytime.
First, the agent is only needed if your private key is passphrase protected.
Second, as explained in "Working with SSH key passphrases", you should be able to automatically launch said agent through a ~/.bashrc resource file, or (for Mac) caching the passphrase in the keychain.

Git Bash - ssh-keygen not working (quits before generating RSA key pair)

It's working fine with Eclipse default git extension and I can do each and every operation using it, I can even generate RSA key.
But when I access git remote using git bash, I got this error:
The authenticity of host '[hostname]:PORT ([IP Address]:PORT)' can't be established.
RSA key fingerprint is SHA256:U...M.
Are you sure you want to continue connecting (yes/no)? fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
and then I removed existing RSA key and tried to generate new RSA key pair and its starts and then quits before completion.
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/userName/.ssh/id_rsa):
userName#example MINGW64 ~/git/path (branch name):
And I also tried to generate a new RSA key using GIT GUI, I got below error
error writing "stdout": broken pipe
error writing "stdout": broken pipe
while executing
"puts $::answer"
(procedure "finish" line 9)
invoked from within
"finish"
invoked from within
".b.ok invoke"
("uplevel" body line 1)
Thanks in advance.
If you are using a recent version of Git (2.19.2 or more), make sure to generate a PEM private SSH key, not an OPENSSH one.
See "Jenkins: what is the correct format for private key in Credentials"
Use:
ssh-keygen -m PEM -t rsa -P "" -f afile
Then try again your git push, from a simple CMD (no need for bash), using a simplified PATH:
set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%

Mac OS X key gen without password, can I remove it?

I generated my key pair on a new computer that I'm setting up for my development environment. I am already using my id_rsa.pub key in several places and don't wish to change it. When generating the key, I entered a passphrase and confirmed it. I believe this means that I must enter the passphrase every time my key is used or accessed, such as during ssh into a server or doing a git push to GitHub. I forgot that I could have just hit the enter key and skipped entering a password during generation.
What I want to know is if I can remove the passphrase so that it is as if I had just used the enter key when I was generating it or so that I can use the same key pair without having to use a passphrase. Thanks!
I found what I needed here:
http://www.thinkplexx.com/learn/howto/security/ssl/remove-passphrase-password-from-private-rsa-key
SSH into a host that has your public key: ssh my_user#myhost
At the password prompt, openssl rsa -in ~/.ssh/id_rsa -out ~/.ssh/id_rsa_new
Enter old passphrase
Back up and replace private ssh key:
cp ~/.ssh/id_rsa ~/.ssh/id_rsa.backup
rm ~/.ssh/id_rsa
cp ~/.ssh/id_rsa_new ~/.ssh/id_rsa
Set key permissions: chmod 400 ~/.ssh/id_rsa
Test it by logging in to the remote again.

Generate SSH key on windows via command to specify email address

I have generated my keys using PuttyGen but need to be able to specify exactly the email address used with the following command but this doesn't work as I get an 'is not recognized as an internal or external command error'
ssh-keygen -t rsa -C "joebloggs#mycompany.com"
Can anyone assist in running this command on Windows 10?
You can use PuTTYgen to generate a key with those settings.
For the key type -t rsa you have to select SSH-2 RSA
and for the email / comment -C "joebloggs#mycompany.com" you have to set the Key comment field to joebloggs#mycompany.com
After clicking Generate your can get your public key from the Public key for pasting into OpenSSH authorized_keys file field (this is the same as id_rsa.pub when generated with ssh-keygen)
If you also need the private key to be saved in OpenSSH format just go to Conversions > Export OpenSSH key (this is the same as id_rsa when generated with ssh-keygen)

Automatically press Enter to continue in Bash

I want to change RSA Keys to open ssh connections without any problems. It works fine, if I use this tutorial but I want to have it done in a bash script. Unfortunately I am asked to enter a passphrase (I want to enter nothing). How can I achieve to automatically press Enter three times in a row, when the script reaches this point?
This thread did not help, because I am not allowed to install new programs on my work PC and the echo | command trick seems only to work for one Enter. Also I need to enter "n" and Enter, if the procedure was already made, to not overwrite any files. How do i achieve that?
If you just need to press Enter a bunch of times this will do it:
yes "" | command
For anything more complicated than that you might want to use expect as suggested in the other thread, which you can install in your homedir without root priviliges.
PS: Please avoid re-posting questions in the future. If you don't like an answer for some reason, just comment on it.
If you want to just create ssh keys in a bash script without requiring any user input, you can specify arguments to ssh-keygen:
# rsa type (default), no passphrase, write to file id_rsa and id_rsa.pub
captain:~> ssh-keygen -t rsa -N "" -f id_rsa
Generating public/private rsa key pair.
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
fe:4a:82:08:0e:ab:b7:02:62:11:4d:3e:79:a4:d3:98 mrb#captain.local

Resources