October 2010
14 posts
2 tags
Examine x509 Certificate
A quick way to examine a certificate in plain text… openssl x509 -text -in cert.pem
Oct 7th
2 tags
Convert Separate Key/Cert Files to a PFX
The reverse of the process of extracting the key/certs from a PFX can be achieved via… openssl pkcs12 -export -in [certificate.crt] -inkey [private.key] -out [package.pfx]
Oct 7th
Recover MySQL Root Password
To recover the password for the root account on a MySQL server use the following steps… (Essentially, it can be done by restarting the daemon without the grant tables) 1. Stop the current mysql process # /etc/init.d/mysql stop 2. Start the daemon without the grant tables # mysqld_safe —skip-grant-tables & 3. Login to mysql as the root user … it will have a blank...
Oct 7th
Content-Disposition Header
In situations where you want a file linked to from within a website to present a ‘Save As’ dialog rather than simply displaying the content … you can inject a Content-Disposition header into the HTTP connection to prompt the browser to do so.  I recently had a situation where I was linking to an uncommon file extension through a reverse-proxy and Internet Explorer wanted to...
Oct 7th
2 tags
Upper To Lower To Upper Case Command Line
Nice trick to pipe command line data through to convert it’s alpha characters to upper or lower case. From UPPER to lower… tr [:upper:][:lower:] From lower to UPPER… tr [:lower:][:upper:] For example… ls /directory | tr [:lower:][:upper:] | sort
Oct 7th
1 tag
Remote Reboot Windows XP
Using the Remote Desktop client to connect to a Windows XP system will not provide you with the option to reboot or restart the remote machine.  This can be done from the command line however.  Open a command prompt (Start->Run->Cmd.exe) and use the command… shutdown -r -t 0 … to open a gui interface to manage the reboot … shutdown -i
Oct 7th
1 tag
Enable Syntax Highlighting In VIM (vi) In Mac OSX
To enable the syntax highlight feature of Vim (vi) on Mac OSX, edit the /usr/share/vim/vimrc file and add the “syntax on” config.  To do this from Terminal.app … sudo vi /usr/share/vim/vimrc …add a new line, “syntax on” and then save and close the file.
Oct 7th
1 tag
Mount ISO (.iso) In Linux
To mount an ISO (.iso) on a Linux system… mount -t iso9660 -o ro,loop /path/to/file.iso /path/to/mount/point In many cases you will not have to specify the “-t iso9660” as most Linux distributions will auto detect that.  The “ro” in the “-o ro,loop” tells this system to mount the .iso read only.
Oct 7th
1 tag
Convert DMG To ISO & ISO to DMG
To convert a Mac .dmg to a .iso image file, open Terminal.app and then run the following command… hdiutil convert /path/to/filename.dmg -format UDTO -o /path/to/filename.iso To convert a .iso image file to a Mac .dmg, also in Terminal.app run the following command… hdiutil convert /path/to/filename.iso -format UDRW -o /path/to/filename.dmg
Oct 7th
2 tags
Strip Leading Zeros In Shell
Nice trick to strip leading zeros from an IP address at the command line (it turn 002.203.017.001 to 2.203.17.1)… echo 002.203.017.001 | awk -F “.” ‘{print int($1)”.”int($2)”.”int($3)”.”int($4)}’
Oct 1st
3 tags
Convert PFX to Seperate Key/Cert Files
Using openssl to extract key and certificate files from a .pfx To extract the private key… openssl pkcs12 -in [filename.pfx] -nocerts -out [private.key] To extract the certificate… openssl pkcs12 -in [filename.pfx] -clcerts -nokeys -out [certificate.crt] To decrypt the private key… openssl rsa -in [private.key] -out [decrypted.key]
Oct 1st
1 tag
Symbols, Mac OSX Keyboard Shortcuts
Mac OSX keyboard shortcut combinations for many common symbols… ™ (trademark) = Option + 2 £ (pound) = Option + 3 ¢ (cent) = Option + 4 ∞ (infinity) = Option + 5 § (section) = Option + 6 ¶ (paragraph) = Option + 7 • (dot) = Option + 8 € (euro) = Shift + Option + 2 ° (degree) = Shift + Option + 8 ¥ (yen) = Option + y ÷ (division) = Option + / ± (plus/minus) = Option + = ≥ (greater than...
Oct 1st
2 tags
HTTP(S) PUT w/Basic Authentiation via Curl
Need to use a secure HTTP PUT over SSL using Basic Auth? curl -T file.txt -u https://[hostname]/[uri] Add a -v to see that connection with verbose output.
Oct 1st
1 tag
Flush DNS Cache, Mac OSX
As a DNS admin, I frequently need to flush my local DNS cache in order to confirm that a change I made on a DNS server was correct.  To do this on Mac OSX, open your Terminal.app and run the following command… dscacheutil -flushcache
Oct 1st
September 2010
2 posts
1 tag
Home & End Keys, Mac OSX
Using Terminal.app on Mac OSX to connect to a Linux/*nix system and work in any text editor (such as Vim) is a bit of a hassle when you are used to the Home and End keys going to beginning or end of line on other systems. Remap the keys in Terminal->Preferences->Settings->Keyboard to the following… End: ctrl+[, [, 4, ~ it should look like this: \033[4~ Home: ctrl+[, [, 1, ~ it...
Sep 30th
1 tag
URL Encode/Decode (Perl)
Snippet of Perl code to URL encode/decode a string… URL Encode: $str =~ s/([^A-Za-z0-9])/sprintf(“%%%02X”, ord($1))/seg; URL Decode: $str =~ s/\%([A-Fa-f0-9]{2})/pack(‘C’, hex($1))/seg;
Sep 30th