Permission issue in WSL2 and gnupg - windows-subsystem-for-linux

I'm trying to generate GPG key and move that key to outside of WSL2.
Generate GPG key and its revocation cert in WSL2
Export keys to Windows by command below:
gpg2 --export-secret-keys --armor "GPG_PUBLIC_ID" > ~/secret-key.asc
This command successfully generates .asc file with permission -rw-r--r--
And my destination directory(/mnt/c) has permission of drwxrwxrwx
So permission seems sufficient.
However, export has failed when the key is exported to outside of WSL or copied to outside of WSL.
gpg2 --export-secret-keys --armor "GPG_PUBLIC_ID" > /mnt/c/secret-key.asc
This command gives error as follows: zsh: permission denied: /mnt/c/secret-key.asc
I'm using Ubuntu 20.04 and package manager is updated.

Root directory fo Windows (C:\) has higher security contraints than other directories. drwxrwxrwx might not reflect real permission in Windows. You should not write files in Windows root directory unless you have a very strong reason to do so.
Try
gpg2 --export-secret-keys --armor "GPG_PUBLIC_ID" > /mnt/c/temp/secret-key.asc
# Create C:\temp in Windows if it does not exist.

Related

Cannot copy ssh key after generation

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

How to access a folder via SMB protocol from ASP Net Core [duplicate]

I am trying to setup a script that will:
Connect to a windows share
Using LOAD DATA LOCAL INFILE, upload the two files into their appropriate db tables
Umount share
Situation:
I can currently vpnc into this remote machine
Problem:
I cannot
mount -t cifs //ip.address/share /mnt/point -o username=u,password=p,port=445
mount error(110) Connection timed out
I am attempting to do this manually first
Remote server is open to port 445
Questions:
Do I even need to vpnc in first?
Do I need to do route add for the remote ip/mask/gw after vpnc?
Thank you!
The mount.cifs file is provided by the samba-client package. This can be installed from the standard CentOS yum repository by running the following command:
yum install samba samba-client cifs-utils
Once installed, you can mount a Windows SMB share on your CentOS server by running the following command:
Syntax:
mount.cifs //SERVER_ADDRESS/SHARE_NAME MOUNT_POINT -o user=USERNAME
SERVER_ADDRESS: Windows system’s IP address or hostname
SHARE_NAME: The name of the shared folder configured on the Windows system
USERNAME: Windows user that has access to this share
MOUNT_POINT: The local mount point on your CentOS server
I am mounting to a share from \\10.11.10.26\snaps
Make a directory under mount for your reference
mkdir /mnt/mymount
Now I am mounting the snaps folder from indiafps02, User name is the Domain credentials, i.e. Mydomain in this case
mount.cifs //10.11.10.26/snaps /mnt/mymount -o user=Girish.KG
Now you could see the content by typing
ls /mnt/mymount
So, after performing your task, just fire umount command
umount /mnt/mymount
That's it. You are done.
no need to install "samba" and "samba-client", only "cifs-utils" using command
yum install cifs-utils
after that in windows share the folder you would like to mount in centos if you didn't do that already ("c:\interpub\wwwroot" in my case).
make sure you share it with a specific username whom your know the password for ("netops" in my case).
create a directory in centos in which you would like to mount the windows share in to ("/mnt/cm" in my case).
after that run that simple command as a root
mount.cifs //10.16.0.160/wwwroot /mnt/cm/ -o user=netops
centos will prompt you for the windows username password.
you are done.

How to create GPG keys via shell script for root user?

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?

Properly set SSH home in GitPortable

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.

~/.ec2/id_rsa-gsg-keypair not accessible: No such file or directory

I'm trying to launch a Hadoop cluster on Amazon ec2, using the instructions in "Hadoop in Action" (also here: http://wiki.apache.org/hadoop/AmazonEC2).
I've set up my private ssh key and configurations, but when I try to launch a cluster using the command-line tools:
hadoop-ec2 launch-cluster test-cluster 2
I repeatedly get this error:
Warning: Identity file ~/.ec2/id_rsa-gsg-keypair not accessible: No such file or directory.
Permission denied (publickey,gssapi-with-mic).
The ~/.ec2/id_rsa-gsg-keypair definitely exists, though, and I did chmod 600 it:
> chmod 600 ~/.ec2/id_rsa-gsg-keypair
> ls -l id_rsa-gsg-keypair
-rw------- 1 my-username
Any idea what's wrong?
You may have already realized this, but the problem is possibly related to the ~/ path usage. Try using the absolute path /home/username/.ec2