we have a windows 2008 r2 server. We installed gpg4win and it works. We can create publick and secret keys and decrypt messages for those that have our public key.
The issue
The gnu install defaulted to my user profile and we would like it to be under a generic one.
We created a directory c:\gpg_keys
According to the documentation on the gnu web site:
gpg --homedir /my/path/
to make GnuPG create all its files in that directory. "
When we run this command this is windows install:
gpg --homedir c:\gpg_keys\ the return is:
gpg: keyring `c://gpg_keys//secring.gpg' created
gpg: keyring `c://gpg_keys//pubring.gpg' created
gpg: Go ahead and type your message ...
the process stops???
When we look at the target directory we have:
08/28/2013 05:14 PM 0 pubring.gpg
08/28/2013 05:14 PM 0 secring.gpg.lock
08/28/2013 05:14 PM 0 pubring.gpg.lock
08/28/2013 05:14 PM 0 secring.gpg
4 files zeroe length created
Please any way to get the target directory for home moved??
The --homedir apparently does not work but the following does:
Home directory:
===============
GnuPG makes use of a per user home directory to store its keys as well
as configuration files. The default home directory is a directory
named "gnupg" below the application data directory of the user. This
directory will be created if it does not exist. Being only a default,
it may be changed by setting the name of the home directory into the
Registry under the key HKEY_CURRENT_USER\Software\GNU\GnuPG using the
name "HomeDir". If an environment variable "GNUPGHOME" exists, this
even overrides the registry setting. The command line option
"--homedir" may be used to override all other settings of the home
directory.
checking with --version shows the directory has been changed.
Here's a ready made solution in the form of a .reg file. Paste this into example.reg, edit, save, then double-click on the resulting file.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\GNU\GnuPG]
"HomeDir"="c:\\edit this\\.gnupg"
The --homedir xxx option is just that - an option. It MODIFIES how some other command works.
As an example, if you have a directory /tmp/gpg containing keyring files and want to see what keys are in them, you might run something like this:
gpg --homedir /tmp/gpg --list-keys
In this example, --list-keys is the command, and --homedir /tmp/gpg is an option which modifies how that command works, i.e. what directory to look in for the keyring files.
When you ran gpg --homedir c:\gpg_keys\, you didn't supply a command at all, so gpg did exactly what it does if you had just run gpg by itself - tried to figure out what you wanted, based on the input it receives. It even told you that it wanted input, when it said this:
gpg: Go ahead and type your message ...
Related
This is something recent with my Cygwin on Win 10. If I do "mkdir folder", then in Windows, checking folder properties and selecting the Security tab gives the popup: The permissions on folder are incorrectly ordered, which may cause some entries to be ineffective.
If I then create a file in that folder from Windows, in order to open that file, I have to first remove one of the permissions entries under Properties>Security>Advanced for that file. That entry indicates "deny special access for the owner of the file".
What is causing incorrect ordering of permissions and also what I believe is the wrong permissions to be assigned to newly-created folder in Cygwin?
Source: Forcing Cygwin to create sane permissions on Windows
Adding the noacl option to this file worked for me on Windows 10 Home with Cygwin x64:
CYGWIN_NT-10.0 3.1.6(0.340/5/3) 2020-07-09 08:20 x86_64 Cygwin
You may need to find where your Cygwin folder is located.
File:
C:\cygwin64\etc\fstab
Contents:
# /etc/fstab
#
# This file is read once by the first process in a Cygwin process tree.
# To pick up changes, restart all Cygwin processes. For a description
# see https://cygwin.com/cygwin-ug-net/using.html#mount-table
# This is default anyway:
none /cygdrive cygdrive binary,noacl,posix=0,user 0 0
After changing the fstab file I had to reboot my PC.
Also, when I used rsync I passed these arguments:
time rsync -avh --delete --progress --chmod=ugo=rwX /cygdrive/s/source/ /cygdrive/d/destination/
I have a script that creates a filesystem archive. For this I need superuser privileges, but I do not wish to run the whole script with sudo, just the specific line that creates the archive.
The problem is, when I prefix the archiving command with 'sudo', the files which are created inside the archive all have my uid (1000), not the root uid (0). When this filesystem is later unpacked into the target platform, and we boot into it as root, attempting to perform actions that require superuser priviliges fails: the system thinks that the root account should have uid 1000, not 0.
How do I make the tar command run as root while also have the correct uid in the result?
tar preserves the permissions, ownership, etc. that the files have on the filesystem by default.
You can override that with the --owner=USER and --group=USER flags.
Additionally, you can tell tar to use the numeric ownership and group information stored in the tar file instead of the name equivalents (in case the names differ on the different systems) with the --numeric-owner argument.
So if the only reason you needed root for the tar command was to set ownership, etc. in the tarball then you don't need that at all.
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 am using cygwin and I am trying to set up an .ssh/config file. Cygwin's folder is in my C: drive. My Home directory is C:\Users\USER. I have noticed that when I edit C:\Users\USER.ssh\config, cygwin does not even notice it (even though it notices the other files I have in my USER folder, i.e. .bashrc). But it does notice the config file if I put it in C:\cygwin64\home\USER.ssh\config.
Is there a way to get cygwin to read the .ssh folder in my USER home directory instead?
Make sure your home directory setup in /etc/passwd matches /home/ Often it is not set at all (second to last field in the ':' delimited line. Then you'll need to restart your cygwin session (exit the terminal, and restart)
That should fix your problem.
This isn't the greatest solution but it works:
ln -s /cygdrive/c/Users/username/.ssh /home/username/.ssh
If /home/username/.ssh already exists, perhaps rename it to .ssh_original or move the files into the other .ssh folder.
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.