Advertisement
opexxx

crypto_cmds

Nov 24th, 2013
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.74 KB | None | 0 0
  1. #############################
  2. # GNUPG
  3. #############################
  4.  
  5. # generate a keypair
  6. gpg --gen-key
  7. # export ones public key
  8. gpg --armor --output pubkey.txt --export 'My name'
  9. # send the key on the server (easier with kgpg)
  10. gpg --send-keys 'My name' --keyserver hkp://subkeys.pgp.net
  11.  
  12. # import someone else's key
  13. gpg --import key.asc
  14. gpg --search-keys 'tnagy1024@gmail.com' --keyserver hkp://subkeys.pgp.net
  15. # encrypt a file
  16. gpg --encrypt --recipient 'tnagy1024@gmail.com' foo.txt
  17. # decrypt a file
  18. gpg --output foo.txt --decrypt foo.txt.gpg
  19.  
  20. #############################
  21. # LINUX
  22. #############################
  23.  
  24. # partition creation using ‘dd’
  25. dd if=/dev/urandom of=/root/linux.bin bs=1024k count=278
  26. dd if=/dev/zero of=/root/linux.bin bs=1024k count=4489 (dvd R)
  27. dd if=/dev/zero of=/root/linux.bin bs=1024k count=4450 (dvd RW)
  28. dd if=/dev/zero of=/root/linux.bin bs=1024k count=700 (cdrom de 700 Mb)
  29.  
  30. # filesystem creation
  31. mkfs -t ext2 /dev/loop0
  32. tune2fs -m0 -c0 -i0 /dev/loop0
  33.  
  34. # script for mounting the volume
  35. #! /bin/sh
  36. DEVICE=/root/linux.bin
  37. sudo /sbin/modprobe cryptoloop
  38. sudo /sbin/modprobe aes
  39. sudo /sbin/losetup -eaes256 -C7 /dev/loop0 $DEVICE
  40. sleep 1
  41. sudo mount /dev/loop0 /crypt
  42.  
  43. # script for unmounting
  44. #! /bin/sh
  45. sudo umount /crypt
  46. sudo /sbin/losetup -d /dev/loop0
  47.  
  48. #############################
  49. # SSH
  50. #############################
  51.  
  52. # Key creation
  53. ssh-keygen -t rsa
  54.  
  55. then copy ~/.ssh/id_rsa.pub on the remote server
  56.  
  57. # To avoid retyping the password over and over again, edit ~/.profile
  58. SSHAGENT=/usr/bin/ssh-agent
  59. SSHAGENTARGS="-s"
  60. if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
  61. eval `$SSHAGENT $SSHAGENTARGS`
  62. trap "kill $SSH_AGENT_PID" 0
  63. fi
  64.  
  65. # for the fist time, call:
  66. ssh-add ~/.ssh/id_dsa
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement