So I created a ssh key and can find the folder but on trying to copy,it won't work.Keeps telling me the system cannot find the path specified
My command prompt is on Windows,
Command
Clip <clip ~/.ssh/id_rsa.pub
Related
I added a ssh key.
ssh-keygen -t rsa -b 4096 -C "my email"
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\user-name/.ssh/id_rsa):testkey
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in testkey.
Your public key has been saved in testkey.pub.
I tried commands like ls -al ~/.ssh and cat ~/.ssh/id_rsa.pub to find it. Didn't help.
Than i created a .ssh folder in my user directory using mkdir ${HOME}/.ssh and tied to create another SSH key. I did it in VS Code so it told me
testkey already exists.
Overwrite (y/n)?
Then i decided to cat testkey.pub and it returned me a key. Than i checked my local repo and found 2 files testkey and testkey.pub
So why it can't save in C:\Users\user-name/.ssh/id_rsa ?
I obviously don't want to store it my local project repo
I am still learning. Was watching Course about Git but got stuck on 22:00 with this problem
Enter file in which to save the key (C:\Users\user-name/.ssh/id_rsa):testkey
You entered filename without full path so ssh-keygen saves the keypair in the current directory. The answer should be
Enter file in which to save the key (C:\Users\user-name/.ssh/id_rsa):C:\Users\user-name/.ssh/testkey
Or
C:
cd \Users\user-name\.ssh
ssh-keygen
Enter file in which to save the key (C:\Users\user-name/.ssh/id_rsa):testkey
To add key in Gitbash Make sure to use to enable ssh agent first.
eval $(ssh-agent -s)
[enter image description here][1]
Now you can add ssh key in git bash using below command.
if you are doing it in windows Git Bash.
ssh-add /c/keyname
How to check if the key is added.
ssh-add -L
you should see the ssh key added here .
Below are the steps:
Open Git Bash and run below command on command prompt to generate public-private key pair ssh-keygen -t rsa -b 4096 -C "your_email#gmail.com"
When you are prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.
Enter a file in which to save the key (/c/Users/username/.ssh/id_rsa):[Press enter]
At the prompt, type a secure passphrase. You can press enter if you want to leave it blank but its not recommended.
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
Go to /c/Users/username/.ssh/ folder and open id_rsa.pub file and copy entire contents of it.
Finally, go to Github -> Settings -> SSH And GPG keys -> Click New RSA (Green Button). Give some meaningful title to the key and paste the public key copied in step 4 above. Now click on Add SSH Key button.
Congrats, you have added public key to github successfully and now you can use gitbash to access github repositories.
Usually, I take a look from git GUI (in Windows). There is a menu about SSL (or SSH) and you can view the imported key.
For an application I'm making I have to use GPG in a root process on machine #1. On some other machine (#2) I want to run a shell script, that creates keys (secret and public) in GPG for user root on machine #1.
First I create a file, key.scr, where I define characteristics for the new key.
When I run
gpg --batch --gen-key /hdd/myfolder/key.scr"
via ssh for user , a perfect key-pair is created and saved in /home//.gnupg
But my goal is to create keys for the user root, who must use these keys in some crontab-job.
I tried the following:
echo "<MyPassword>" | sudo -S gpg --batch --gen-key /hdd/myfolder/key.scr
and
sudo -u root gpg --batch --gen-key /hdd/myfolder/key.scr
I also placed
gpg --batch --gen-key /hdd/myfolder/key.scr
in a shell command file , and ran
sudo <BatchFile>
but I only messed up the .gnupg folder for (the access rights for several files in this folder are changed to root - root, so they are not readable any longer by .
So, what is the proper way to create via ssh GPG keys which can be used by user root, while root access is not possible via ssh?
I installed ssh-copy-id through Homebrew.
When I type ssh-copy-id -i mykey.pub [path to remote] I get the following error:
/usr/local/bin/ssh-copy-id: ERROR: failed to open ID file './mykey': No such file or directory
It appears that it's not finding the key because the regex is cutting off the .pub. What am I doing wrong?
It turns out that ssh-copy-id checks whether there is a valid private key in the same directory as the public key it's uploading.
I was uploading someone else's SSH key so they could access a server. I don't have their private key on my machine, which is why the error occurred.
One option is to just manually remove that check from the script, but it's hacking the Homebrew code.
My solution was to run touch mykey to create a blank file using the filename syntax of the corresponding private key to the public key I was uploading (mykey.pub).
Thanks for your explanation. I have resolved the issue by following these simple steps
[ceph#monitor ~]$ ssh-keygen -t rsa
[ceph#monitor ~]$ ssh-copy-id ceph#osd-0
I would very much like to take my Git install with me wherever I go, so I have installed GitPortable via PortableApps.
Unfortunately, the OpenSSH utilities available in git-bash insists on placing/searching for the .ssh folder in a nonsensical place (C/.ssh).
Now, I have seen others with the same problem, but the solution generally was to set HOME as a Windows environment variable. But this is not working for me.
From the usual Windows command prompt:
C:\Users\snb>echo %HOME%
C:\Users\snb
Showing that the environment variable is apparently set correctly.
From git-bash:
snb#SNB-WORKSTATION /c/Users/snb
$ echo $HOME
C:\Users\snb
Showing that git-bash agrees. However if I test out an SSH command, OpenSSH has the completely wrong idea of where to locate the .ssh folder:
snb#SNB-WORKSTATION /c/Users/snb
$ ssh -T git#bitbucket.org
Could not create directory 'C/.ssh'.
The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established.
RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
Are you sure you want to continue connecting (yes/no)?
I'm at a loss at what to do to make OpenSSH in the GitPortable installation understand where my home directory is. Do you have any ideas other than giving in and just installing Git for Windows?
EDIT:
The OpenSSH version is:
$ ssh -V
OpenSSH_6.6.1p1, OpenSSL 1.0.1i 6 Aug 2014
The command uses the correct .ssh folder location in a Windows command prompt when using git-cmd.bat:
C:\Users\snb>ssh -T git#bitbucket.org
The authenticity of host 'bitbucket.org (131.103.20.168)' can't be established.
RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,131.103.20.168' (RSA) to the list of known hosts.
Enter passphrase for key '/c/Users/snb/.ssh/id_rsa':
But I truly hate cmd.exe, I need this to work for git-bash! :)
The SSH command git-bash uses is:
$ which ssh
/bin/ssh
The /bin folder is located inside the GitPortable installation, so this would be the OpenSSH version distributed with GitPortable.
This GitPortable is based on msysgit PortableGit-1.9.5-preview20141217 github commit
The proper path for HOME in a bash session should be set with:
export HOME=/c/Users/snb
That would make it compatible with ssh in a unix shell.
Using posix path seems safer considering Git is running on top of a posix run-time environment.