how to use a public key

Hi experts,
if you find someone's public key as follows, how do you use it
to encrypt the file you want to send? I mean, you can import
a public key by issuing "gpg --import blahblah.gpg", but the
following is a .asc file, not a .gpg file. how can i import
it to my keyring?



-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.0.7 (NetBSD)

mQGiBDz9Q1YRBAC6LqCWvyDMmJhQZHWxgUZjYBnBqghb4RuckW3R9FFtxXGW2qUr
QLvbjI9n7vyh7pVd4lphogTp/J8dv9O1pzpxFotr6oC6pq4kUNeciURdEao+oyXk
hBqoXDU5lVS00SEYkUZXArGHlJfUjGUMdciO/74H/555dMuPjTbLn27b1wCgqfbE
YCasmzzGhg/3EfX3TF2yv2cD/1qHRM6ZqU1aRLGYvqtf4rtLzKSU1en65nxsiuBI
tSXJD+2CE6gMOF++pMhQO1gv4N5mcIx5Csw30VG+ubpYyPs899hbnRgstNLnuRA0
MFdA/8HLJ4SfrV50FKE6RzX6xNdENSR6UE2JmRf1dXAGNmWCbOpkQyPiRkozyyHD
JxbuBACII0KGOE9p2IzuN3oC9g0C7AHL4OJEnn4x7iye2/o3u/DPEMtKJOj4qFLP
G8Dd0C5y7GwRjzJ8MiBvOn11wkaxo7neKJUxrHFfuGlJ+vdlKLA7wpywRGqVJ+1b
3pmIn4Ky4NOQuCqzk/aKZbYCmROHDbAHzjin5wx2bRPEW/AO4LQfa2VuIHpoYW5n
IDx6c3lneW1AbG9uZXN0YXIub3JnPohfBBMRAgAfBQI8/UNXBQkACTqABAsHAwID
FQIDAxYCAQIeAQIXgAAKCRDiGx8FK/sQEriSAKCTpv6otDekhxCJAlNqggDvhp57
7QCfVt9/y9i8jLy2AcZRMB3lqT1ec2i5AQ0EPP1DXBAEAJafra002gjCuMSsI7qo
tKz443+fR1GH7X7AQ/5dA/wTb8W7nBP10MbWzP9OxLEt+XygFreKE1r9lBXnucVJ
vZAo4Z/lXLw8uSSzf+nuf7h2lw3GXkPTL2iMRiiypMFXzd1f90sl4T7P6IeVhOQx
/ssZXSU25fNdBtrIFpryqf1zAAMFBACJT+gcCDih3I8QvlNHXw86nzom0r6mJel4
NL6803tS4P3ebFGNU7Q7t63OW9aRblBolh8//u/TYUU7GyV8R+ktK0qGC9qUweRa
+On1a0AeZJCPpx+OEg2MgzoCTKCMchAm9tNsNVyBHWFKpfS/y3/AF19VYwOebzTn
p5pFYB4xo4hMBBgRAgAMBQI8/UNcBQkACTqAAAoJEOIbHwUr+xASCbsAn0em3R7L
ds5pQE2hNoK9PXyZhCQ/AJwJp/t4m5368YwzzL9yCFZaquZGeQ==
=rYbE
-----END PGP PUBLIC KEY BLOCK-----


Thanks a lot,
KEN

ken021600Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ahoffmannConnect With a Mentor Commented:
1) why did i still get the "using insecure memory" warning?
While you're running gpg some data is stored in memory, for example pass phrases. On most systems a root user is able to dump the memory and read the pass phrase there. Even if it es encrypted, all necessary keys are in memory too, somehow. So an experianced user could do nasty things.

2) why did i have to create the directory ".gnupg" manually? Why couldn't it be created automatically?
Probably it's simply a missing feature.
0
 
ahoffmannCommented:
you import is like:
  gpg --import blahblah.asc
then you encrypt it like:
  gpg --encrypt -a -r <id or email of imported key> file
0
 
ken021600Author Commented:
Hi ahoffmann,

nice to see you again!

due to some reason i don't know, EE didn't notify me of any replies by email:) anyway, i'm here.

just to clarify: are you saying that i should "copy and paste" the above asc file (if i found it on someone's personal website) and save it as an asc file, then import it as you showed me?  and where should i start? i mean should i include the "-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.0.7 (NetBSD)" bit into the asc file i save?




Thanks,
KEN
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
ken021600Author Commented:
just got another question:
when i issued "gpg --gen-key" at the prompt as a non-priviledged
user,
i got the following output:

gpg: Warning: using insecure memory!
gpg: keyblock resource '/home/myname/.gnupg': file open error

gpg: keyblock resource '/home/myname/.gnupg': file open error

Please select what kind of key you want:
1)...
2)...
4)...


i got stumpted by these warning messages and tried to re-issue "gpg --gen-key" as the root. This time i didn't get those warnings.


my questions are:
why did i get these warnings? what do they imply? why did i get them as a common user, but not as the root? how can i, as a common user, generate keypairs without getting
these warnings?

KEN
0
 
ahoffmannCommented:
> ..  i mean should i include the "-----BEGIN PGP PUBLIC KEY BLOCK-----
yes

> gpg: Warning: using insecure memory!
that's ok (except you care about it:)

> gpg: keyblock resource '/home/myname/.gnupg': file open error
> gpg: keyblock resource '/home/myname/.gnupg': file open error
This error must be fixed, it's probably due to a permission problem (while creating .gnupg directory)
.gnupg should have permissions 700
0
 
ken021600Author Commented:
I found the mode for /home/myname is drwx------. so why i still got the "file open error"?

and before finalize this question, would you mind spending 3 minutes explaining to me the nature of the problem? I mean you showed me how to solve my problem, but didn't tell me why the problem occured. I think I can learn a lot from gurus like you by exploring the nature of problem. Otherwise   I will never be able to know what the "real" problem is.

Thanks so much,
KEN
0
 
ahoffmannCommented:
> ..  is drwx------
that's ok.

>  so why i still got the "file open error"?
out of ideas (from remote) sorry.
Is gpg owned by root and has **not** set the SID bit?

> ..  nature of the problem?
which pronlem?

Anyway, gpg is very picky about anything concerning security, for obvious reason. It does this 'cause it will inform you about possible way to to compromice even the security of public key structures. That's why it prints errors and warnings. Keep in mind: it's **your privacy** which is in question !

Unfortunately my experiance is not good enough to give more details about the "error open file" ('cause of historical reason I'm still bound to pgp):

Hope this helps anyway.
PLease check the docs about the errors, might be simpler than giving hints here, just out of my finger tips ...
Feel free to ask more then.

Cheers
Achim
0
 
ken021600Author Commented:
Hi Achim,

I found the following in /usr/bin:
-rwxr-xr-x  1  root  root ...     gpg
-rwxr-xr-x  1  root  root ...     gpgv

i changed their modes to 777 and issued "gpg --gen-key" as a normal user. but i still got that warning and "file open error"...

another quick question is: can i use gpg to encrypt/decrypt non-english characters such as Japanese or Chinese?

Thanks,
KEN
0
 
ahoffmannCommented:
file permissions are ok, you don't need 777, 555 is best.
Does the directory .gnupg exist? can you create it with mkdir, and then chmod 700 ?
You can encrypt anything, even plain binary data.
0
 
ken021600Author Commented:
i created the directory .gnupg and changed its mode to 700. then i issued "gpg --gen-key" as a normal user, and this time i got the following:

gpg: warning: using insecure memory!
gpg: /home/myname/.gnupg/secring.gpg: keyring created
gpg: /home/myname/.gnupg/pubring.gpg: keyring created
Please select what kind of key you want:
1)...
2)...
4)...

so it seems that "file open error" is gone...
but,

1) why did i still get the "using insecure memory" warning?
2) why did i have to create the directory ".gnupg" manually? Why couldn't it be created automatically?

Thanks,
KEN
0
 
ken021600Author Commented:
Great!

Thanks Achim!

See you next time!
KEN
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.