Create an SSH Key Pair on macOS and Linux

SSH keys are important in different authentication mechanisms. Developers mostly use them for git authentication to a remote repository.

With ssh-keygen it is possible to create a so called key pair. One is the private key, which stays untouched on your disk, and the other one is the public key. The second one is the one you need to store on the server you want to authenticate yourself. This could be a site like GitHub for example.

ssh-keygen creates a key pair.

cat ~/.ssh/id_rsa.pub can be used to view the public key directly in the terminal. Of course you can open this file with any other editor. If any website demands a public SSH key, the contents of this file is what you need to copy paste.

Create an Image File from any Medium on macOS and Linux

This post is about how to basically pack a whole volume (like any partition) into a so called image file. This is mostly used to create image files from bootable CD or DVD installation media.

First take a look at all volumes.

  • Use this command on macOS: diskutil list

  • On Linux, you have to use one of the following: lsblk, fdisk -l or parted -l

The next command copies bit by bit of the source volume to a target image file: sudo dd if=[path/to/source/volume] of=[path/to/image/file.img] bs=1m

Here’s an example: sudo dd if=/dev/rdisk# of=~/Desktop/image.img bs=1m, where # is the volume’s index.

Symbolic Linking on macOS and Linux

On Linux and macOS it is possible to create reference files, so calles symbolic links, that point on a file on the filesystem. This is handy if you want e.g. to have a folder holding symbolic links to different applications.

Here’s the command for this: ln -s /original/file /symbolic/link

Open the Working Directory in the Terminal as a Window

The terminal is powerful, but sometimes a graphical window can be handy. While working with the terminal, you might want to open the current working directory in your windows manager, Explorer for Windows, Finder for macOS or Nautlius for a GNOME-powered Linux.

  • Windows: ii .
  • macOS: open .
  • Linux (Nautilus): nautilus .

Nuke a Disk on OS X

For security reasons, or in case you want to sell your hard drive, formatting the disk is not enough. The reason lies in the formatting process itself: formatting only resets the content list of a drive. Your data is still written on the disk, as long as you do not overwrite them.

There are different apps providing different overwriting strategies. The following simple comand overwrites a disk once with a random sequence of 0s and 1s:

cat /dev/random > /dev/disk[X]

X is here the index of the disk you want to overwrite. With

diskutil list

you can list all your partitions.