Monthly Archives: December 2014

Mac OS X : Show hidden files in Finder

To show the hidden files execute the command below in a terminal window:
defaults read com.apple.finder AppleShowAllFiles -bool YES

To hide these files again execute the command:
defaults read com.apple.finder AppleShowAllFiles -bool NO

While Apple helpfully provided a keyboard shortcut for use in open and save dialogs, they didn’t do the same for normal Finder windows. Luckily, it’s not too tricky to set up a keyboard shortcut yourself.

To start, open up Automator (in the Applications folder) and choose a Service template. From the library choose “Run Shell Script” and drag it across to the workflow area. In the text box paste the following command:

STATUS=`defaults read com.apple.finder AppleShowAllFiles`
if [ $STATUS == YES ]; 
then
    defaults write com.apple.finder AppleShowAllFiles NO
else
    defaults write com.apple.finder AppleShowAllFiles YES
fi

Finally, change the “text” drop-down menu to “no input” and then save you workflow as “Toggle Hidden Files”.

Now if you go to the Finder menu and look under Services, you should find a “Toggle Hidden Files” option. To add the keyboard shortcut, go to the Keyboard section of System Preferences and click the Keyboard shortcuts tab. Select Services from the list on the left, then scroll down to the bottom of the list on the right to find “Toggle Hidden Files”. Double-click on the area to the right of it, then press the keyboard shortcut you want. I used Command-Shift-. (dot).

Share

Mount virtualbox shared folder

Mount a shared folder with Ubuntu guest (and Mac OS host):

# Downloads == Name of the share in Virtualbox shared folder
# /mnt/Downloads == Directory on Ubuntu guest
# uid=1000,gid=1000 == Execute the 'id' command to get these values
sudo mount -t vboxsf Downloads /mnt/Downloads -o uid=1000,gid=1000

GIT logoIn a dual boot configuration with NTFS it is sometimes necessary to mount a partition as read only (for example when you have Windows 2008 quick start enabled; see also this link). The command below lets you do this:

# mount ntfs read only
sudo mount -t "ntfs" -o "uhelper=udisk2,nosuid,uid=1000,gid=1000,dmask=0077;fmask=0177",ro "/dev/sdb5" "/media//Data"

 

 

Share

Public-key cryptography

cryptoYou give other people your public (encryption) key. Other people can encrypt data with your public key which you can only decrypt because you have the private (decryption) key for the public key that is used.

Generate a key pair (private / public) with 2048 bits length:

openssl genrsa 2048 > key.pem

Generate a password protected key pair (private / public) with 4096 bits length:

openssl genrsa -des3 -out key.pem 4096

Generate the public key from the private key:

openssl rsa -in key.pem -pubout > pub.key

Create a symmetric key (base 64 for convenience) and store in file:

openssl rand -base64 32 > symmetrickey.txt

Encrypt the symmetric key file with your public key:

openssl rsautl -in symmetrickey.txt -out symmetrickey.bin -pubin -inkey mypubkey.pem -encrypt

Decrypt the symmetric key with your private key:

openssl rsautl -in symmetrickey.bin -out symmetrickey.txt -inkey myprivkey.pem -decrypt

Public-key cryptography, also known as asymmetric cryptography, refers to a cryptographic algorithm which requires two separate keys, one of which is secret (or private) and one of which is public.

Although different, the two parts of this key pair are mathematically linked. The public key is used to encrypt plaintext or to verify a digital signature; whereas the private key is used to decrypt ciphertext or to create a digital signature.

The term “asymmetric” stems from the use of different keys to perform these opposite functions, each the inverse of the other – as contrasted with conventional (“symmetric”) cryptography which relies on the same key to perform both.

The strength lies in the fact that it is “impossible” (computationally unfeasible) for a properly generated private key to be determined from its corresponding public key.

Thus the public key may be published without compromising security, whereas the private key must not be revealed to anyone not authorized to read messages or perform digital signatures.

Public key algorithms, unlike symmetric key algorithms, do not require a secure initial exchange of one (or more) secret keys between the parties.

Each user has a pair of cryptographic keys – a public encryption key and a private decryption key. Similarly, a key pair used for digital signatures consists of a private signing key and a public verification key.

In symmetric-key encryption, each computer has a secret key (code) that it can use to encrypt a packet of information before it is sent over the network to another computer. Symmetric-key requires that you know which computers will be talking to each other so you can install the key on each one. Symmetric-key encryption is essentially the same as a secret code that each of the two computers must know in order to decode the information. The code provides the key to decoding the message.

The first major symmetric algorithm developed for computers in the United States was the Data Encryption Standard (DES), approved for use in the 1970s. The DES uses a 56-bit key.

DES has been replaced by the Advanced Encryption Standard (AES), which uses 128-, 192- or 256-bit keys. Most people believe that AES will be a sufficient encryption standard for a long time coming: A 128-bit key, for instance, can have more than 300,000,000,000,000,000,000,000,000,000,000,000 key combinations

Share

sudo without password on Ubuntu

GIT logoFor some commands in unix you need elevated priviliges. For this the sudo command is invented. It is very inconvenient to enter the password every time you execute the sudo command (especially if you have logged in with your ssh keys in the first place).

To prevent sudo from asking your password you should edit the file /etc/sudoers . First check which groups you are in (preferable use the “username” group; the one in which you are the only memeber). Start editing the sudoers file with the command: sudo visudo

below the lines

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

Add one extra line:

%yourgroup ALL=(ALL) NOPASSWD:ALL

Restart the sudo service with

sudo service sudo restart

Logoff and logon; execute a sudo command; no password asked…

Share

Synology and usb share numbering

synology_diskstationWhen you connect a USB device to your Synology diskstation a share is created with a sequence number. The last number assigned (and the device id it is assigned to) is stored in the file /usr/syno/etc/usbno_guid.map.

You can delete devices you no longer use and assign your own numbers here to the USB shares. This is very usefull when you have backup tasks that backup to a specific USB share (like I have).

Share