Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm working on a lab for my computer security class, and one step is giving me problems. Here is the assignment. And here is all the work I've done up until step 11. It is step 11 that I am having trouble with.
11. Use gpg and your own private RSA key to digitally sign aes.key.asc.
Digital signature must be appendedto cipher and stored in
key_signed.txt
The problem is that when I do the following command
gpg --sign -o key_signed.txt -a aes.key.asc
Expected output (by assignment):
My output instead looks like this:
root#bt:~/lab2# cat key_signed.txt
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.10 (GNU/Linux)
owFl0l2I2wQAwPFe9+Vy3Hanc2woszsO3cy8Num37IZpkyZpk7Rp2iatTEibz/ba
pvlo0p4OPEFxgpuCHPOEMbhDkfPpThHFKQhyE5FxB3ObIuhAwSETwcncPcgGPvl/
/D//zo5t8/lH4PXKpjC8NDHygX+zPirK1nRLHkyLVoM9PD7x1L1SGE4ygQJeCNAY
xyE4dv8CFdm09G7n6QDecQp4oA9NR6ahUOAIzpSDlN5xvKMAoLEYjUQwgjW8Dl63
2girgLSjiyasQSEQUnSGBHNEYqBKBJ5xgyittmIxMdEX23aCK5YloNVqZgwiVnXp
nleudpOFrKOS4VmIAbNxvu+CTFQcGGXHLcj1aDHJtsR62KONBKVGzY6DWgYwSFCR
uqJ4kmIQ5CxPihZkcbJcEKJIsiLhrWK3LIAVZ5bvcnCiojIFOS/YkZQDd6l0xaiF
AJPCa5moZTWUVh9EaDetxtksbVJOJIFDZFvkbQKuZodSpFHKMPVKFgqlzSZKpXXZ
hijdsoEUVBOdODzMDVuxZqqDgVXdrYZ4zgkyTtMjI/WiiQsuR9swGs6jVC1YcglW
iIN2123CBaoKDHGP08iYgqkVXO0FkyBaqeFVsdELSyZLx3FKJfJ2wyCwZK6PyIZc
6pNefRaV0STSaAvlPpAv6kok35cLhBbSLTyL5aSEW7ZKDlwqixk8Ey+FwJzsdvRY
z2W6GI9ZEgGl9W4KroXUeNYBOnqeSGQHHDvweIblgskcj1JlIYkh6aHhSEKe0ayB
Ggl3zKGRSGl9WshRIS9sRxOOqeUlDUhKStNCLC3DGgOpQbZcNzhsm66d4mu2WeUb
sbYiK4UQBUVdEu1JmIDnpbAdVqP5ZtGtZcKAKkV4LRuuVsoUJzAQnCNls+jOzAAz
PbeiAvdFYgz6f6Wvjjy63Tfi9+3c4b8H2gfsHv9PPLZ3192drXNfn159e+fa+cdO
oSs/TI59863/l5W1z5bPPOfLH/yyCh64sfsvjZDetc+uDVen9p67dmHsqruAXXy/
5d9YKl7fton8+NF+y395Abk7svLV+WOfcovro0tHkat7tr7nrh8XPpw7+Ru0n89d
GEy99dON5uLnD792wtq6CF+7/Ypve+DI7BP2k7fihQcu828i1M2lE3Ppv/Hl9V2/
v+A486t3rpxS3qBPxzKPHN/x5+O+Q/b8sfk2v3HTe+ZSe9+tZw+vPr+nKLz8xZVD
L0rguL61oB+gJhdHT05MDt+5/c/PzYD2qzX+EsPpZ6b8370+t5x+sM7MPPTenU82
Ph4N7ftj/OBCBP0X
=ZfM8
-----END PGP MESSAGE-----
I think I just need to use the >> stream redirection operator to append the signature to the encryption but everything I have tried doesn't result in something that starts with
-----BEGIN PGP SIGNATURE-----
What to do to get the expected output?
Looking at your expected output, as near as I can tell the assignment is asking you to "clear sign" the encrypted file. So try this command:
gpg --clearsign -o key_signed.txt aes.key.asc
I found this pretty good reference that might be helpful. There are many others available if you do a web search.
Have a look at GnuPG's --clearsign flag. From man pages:
--clearsign
Make a clear text signature. The content in a clear text signature is read-
able without any special software. OpenPGP software is only needed to verify
the signature. Clear text signatures may modify end-of-line whitespace for
platform independence and are not intended to be reversible. The key to be
used for signing is chosen by default or can be set with the --local-user
and --default-key options.
Use this command to get expected output:
gpg --clearsign -o key_signed.txt aes.key.asc
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 days ago.
Improve this question
sudo apt-get install tesseract-ocr; I ALSO TRIED USING !!!!!!!!
Error opening data file /kaliferganes/share/tesseract-ocr/4.00/tessdata/eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
Exception in thread "main" net.sourceforge.tess4j.TesseractException: javax.imageio.IIOException: I/O error reading PNG header!
I have the following issue:
For now I have successfully added travis notifications to slack channel by editing the travis.yml file. My next step is adding data encryption. I've gone through the slack manual about travis and found that I have to add something the following line of code:
language: bash
travis encrypt "account:token#channel_name" --add notifications.slack
notifications:
slack: account:token#channel_name
Without the second line of code the travis worked perfectly and notifications were send to the channel but after I've added the line of code supposed to do the encryption, travis failed with the following output:
The error was "could not find expected ':' while scanning a simple key at line 2 column 1".
I've also tried to add
.rooms
after
notifications.slack
or to remove the channel name from the line supposed to do the encryption but without any success. I've added : before travis encrypt but still have the same error!
Thank you in advance!
Just in case someone is looking for an answer. You need to run that command with the Travis CLI. Install it and run travis encrypt "account:token#channel_name" --add notifications.slack in the folder of the repository you want to add the slack integration.
I would like to use Hadley Wickam's secure package from GitHub.
The example usage isn't explicit about how to create keys and where to store them and I'm messing something up (possibly more than one thing).
I installed the package
# install.packages("devtools")
devtools::install_github("s-u/PKI") # needed for bug fixes not currently on CRAN
devtools::install_github("hadley/secure")
set up a vault folder:
dir.create("vault")
Then the next step is to add a user / key:
secure::add_user("hackr", local_key())
and of course if I literally run that last line as-is it says
Error: No key matches id_rsa
Because I don't have a key. So, I used PuttyGen to create a public/private RSA key pair.
I saved them to my desktop and tried putting the full path in the command above:
secure::add_user("hackr", local_key("C:/Users/hackr/Desktop/r_public_key"))
But that didn't work:
Error: No key matches
Then I tried saving the public key in the vault and doing:
secure::add_user("hackr", local_key("r_public_key"))
but I got the same error. Next I tried putting the public key in the working directory (one directory higher than the vault) but got the same error.
Finally, I tried copying the keys to C:\Users\hackr\.ssh but that also led to the same error.
I suspect I need to save the key somewhere special (in Windows I'm not sure where that would be?) and/or I am using the wrong type of key since PuttyGen is for SSH (?).
It looks like local_key is assuming your key is stored in ~/.ssh (which is a reasonable assumption). By default it assumes that the file is named id_rsa.pub so if you've renamed it then you'll need to pass the name into local_key.
I haven't used this package but always remember those wise words "Hack-R view the source"
The issue is that Hadley's local_key() function is assuming your key is stored in ~/.ssh which is where the commands below will place it by default, and name it id_rsa.pub. If you have a different setup, you can change the defaults, or you could simply follow the steps below.
Step 1
Go to https://help.github.com/articles/generating-an-ssh-key/
Read up. It's useful stuff to know.
It will tell you to do this in the console:
ssh-keygen -t rsa -b 4096 -C "your_email#example.com"
Set a passphrase. Remember it.
Then enter this:
ssh-add ~/.ssh/id_rsa
Enter your passphrase.
Step 2
Your secure::add_user("hackr", local_key()) should work now.
I need to check to see if a file is a valid pgp encrypted file or not. Some pgp files that we get have an extension of pgp and some dont. I need to check to see which of the files are pgp encrypted files and which are not. Please let me know if there is a way to tell.
The only certain way is to attempt decrypting the file (e.g. with gpg) and interpret the error output. Unless you limit input to ascii-armored files, in that case you can check for the armor.
The python-gpgme library is a Pythonic wrapper for GPGME, the library allowing programmatic GnuPG access.
If you have some files that may or may not be GnuPG encrypted:
$ head --bytes=1024k < /dev/urandom > lorem
$ head --bytes=1024k < /dev/urandom | gpg --encrypt --recipient DEADBEEF > ipsum
With the gpgme module you can attempt to decrypt the files:
import gpgme
import io
context = gpgme.Context()
for infile_path in ['lorem', 'ipsum']:
with open(infile_path, 'rb') as infile:
outfile = io.BytesIO()
try:
context.decrypt(infile, outfile)
except gpgme.GpgmeError as exc:
if exc.code == gpgme.ERR_NO_DATA:
print(
"Not a GnuPG-encrypted file: ‘{path}’ ({error})".format(
path=infile.name, error=exc.strerror))
else:
print(
"Error decrypting file: ‘{path}’ ({error})".format(
path=infile.name, error=exc.strerror))
else:
print("Successfully decrypted: ‘{path}’".format(
path=infile.name))
That lets you handle three conditions:
The gpgme.Context.decrypt method fails, and the error code is gpgme.ERR_NO_DATA. This means the data stream was not recognised as GnuPG-encrypted data.
The gpgme.Context.decrypt method fails for some other reason. You'll need to decide which other errors you care about here.
The gpgme.Context.decrypt method succeeds. Obviously, the file is a correctly-encrypted file.
I have a CSV file and I want to work on it I've tried to read it by using this code
d = read.table( pipe( 'ssh don#140.184.134.189 "cat cluster.csv"' ), header = T )
But I get no result and get this message:
"error in read table"
Without asking about my password.
Also, how do you run an R script fes.r that is located on the same server?
You can first try this, continuing along the lines you are on:
> d <- read.table(pipe('ssh -l don 140.184.134.189 "cat cluster.csv"'))
don#140.184.134.189 password: # type password here
If you don't get prompted for a password, then there is likely a configuration problem with your ssh. Please note that ssh has to be installed and in your $PATH (meaning R can invoke it from anywhere it is running).
If this option doesn't work, then you can try using scp from the RCurl package.
Try the following:
x = scp("140.184.134.189", "cluster.csv", "PASSPHRASE", user="don")
Here you should replace "PASSPHRASE" with the password of your local SSH key.
One other thing to check is whether "cluster.csv" is really the correct path to your file on the remote server. But it seems that you are not even getting this far, so fix the ssh problem first.
Hat tip to this Stack Overflow post for inspiration.
You could take a different approach and install Rstudio server on your remote linux machine.
Rstudio server
You can avoid the password problem by setting up an ssh key pair, and adding your public key to the ~/.ssh/authorized_keys file on the server.
You can see how to run an R script from command line here: Run R script from command line