Shell commands

A list of commands I’ve used over the years.

Tagged

Turis Omnia default config files

I tend to forget that the default configuration files for packages (if distributed) are in /etc/config and that I should update those, as the /init.d scripts pull the defaults and generate files each run.

Tagged ,

HP LaserJet 1018 on macOS

Nothing better than spending the weekend trying to make your printer work with macOS. HP LaserJet 1018 isn’t officially supported, and I always forget what I did last time…

Not anymore!

  • Download and install the latest drivers, 5.1 at the time of writing.
  • Open Printers & Scanners
  • Connect your device to a USB port
  • Click the + button to add a new printer
  • You should see your device in the list
  • Pick it, and manually select the driver for HP LaserJet 1022

If there is one thing Windows does better, it’s drivers! I don’t even recall when was the last time I’ve plugged something that Windows wasn’t able to detect.

Tagged , ,

GPG File/Folder Encryption

GPG is an awesome open-source cryptographic library. One of it’s uses is data encryption. Most of us use file-hosting services like Dropbox, and some of us keep confident stuff in there like passwords, 2FA recovery keys, or CC info. I won’t argue that this is a bad idea, since it’s pretty convenient, but only if the files are properly protected.

The example below uses a folder, and since gpg can be used on a single file only, we archive the folder, and pass it to gpg. For decryption, it goes in reverse order, decrypt then extract. If you want to encrypt a single file, just remove the tar pipes.

Encryption:
tar -cz 2FA/ | gpg --s2k-mode 3 --s2k-count 65011712 --s2k-digest-algo SHA512 --s2k-cipher-algo AES256 --compression-algo BZIP2 -co encrypted_file
Decryption:
gpg -d encrypted_file | tar -zx

Explanation of options:

  • Use --symmetric (-c) to encrypt a file with a passphrase. Symmetric here means the same passphrase is used for both encryption and decryption.
  • Use --output (-o) to specify the output file.
  • Use --compression-algo to specify the compression algorithm for the output file.
  • Use --s2k-cipher-algo to specify the symmetric cipher algorithm used to actually encrypt the message.
  • Use --s2k-digest-algo to specify the digest algorithm used for hashing passphrases in various operations (e.g., the symmetric passphrase specified when using -c).
  • Use --s2k-mode to choose how the passphrases for symmetric encryption are mangled.
  • Use --s2k-count to specify how many times the passphrases mangling for symmetric encryption is repeated.
  • Use --decrypt (-d) to decrypt an encrypted file.

To get a list of supported algorithms, use gpg --version.

Tagged , , ,

OpenWRT and PPTP Pass Through

I wanted to setup a router for VPN. Use the WAN port to connect it to my main router to get internet access (DHCP), and then connect the router using PPTP to a VPN Server. For some reason I had trouble setting the firewall on my main router to properly handle it. Ended up installing this package, and it worked like a charm:

opkg install kmod-nf-nathelper-extra

Source: http://wiki.openwrt.org/doc/howto/vpn.nat.pptp

Tagged , , , ,