Monthly Archives: April 2013

Vim encryption , encrypting with vim and blowfish.

vim
I am always on the search for the other ways to encrypt my documents on a server.
I’ve used gpg keys, gpg symetric encryption, but this one seems to fit the bill the best.
Encrypting with vim is a very painless process, it does take some setup, but not much, I promise.

The first thing I do is to setup an alias in my .bashrc file. I alias the following :

alias vime=”vim -u ~/.vimencrypt -x″

vime is short for “vim encrypted”, at least in my head wink
WHEW! Step one finished, that was easy! ……hey, where is that “easy button” again ?

Next is to edit/and or/create a separate .vimrc just for this, and I name mine .vimencrypt
This file will be in your home directory. ~/.vimencrypt
It contains the following:

source ~/.vimrc 
set nobackup 
set noswapfile 
set nowritebackup 
set cm=blowfish

Note: Since Vim 7.3 (2010-08-15)(and newer), vim can now use Blowfish encryption.
If your using an older vim — remove the “set cm=blowfish” line. It will then default to crypt for encryption.

I know, very complicated right ? wink That’s it folks, you are now READY to use encryption with vim!
Now, simply type “vime something.txt” and you’re on your way.

You will then see:

Enter encryption key:

Enter same key again:

If you entered the same key twice, then you should be presented with a normal vim interface.

If you use “vime” to encrypt the document the first time, it will stay encrypted.
You can then just use vim normally to edit it endlessly (vim will ask for your password, you only have to use “vime” on the initial creation of the document), and it’s encrypted when you close it.

Now you will see VimCrypt~02……. when you cat your encrypted file, and it’s encrypted with blowfish, a MUCH MUCH stronger encryption than just “crypt” which can be broken fairly easily.

> cat test VimCrypt~02!sD~wLПYEx

I hope you have fun with vim and encryption.

7 things to do after installing Linux Mint 14

1. Update packages via update manager: 0:12

2. Install additional drivers: 0:52

3. Install ubuntu-restricted-extras: 1:55

4. Select a download server: 2:45

5. Install Firestarter (firewall program): 3:56

6. Install VLC Media Player: 5:35

7. Configure keyboard shortcuts: 6:37

Converting .wma files to .mp3 files

bash
How to convert .wma files to .mp3 files.

Requires, mplayer and lame

for i in *.wma ; 
do mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$i" && lame -m j -h --vbr-new -b 160 audiodump.wav -o "`basename "$i" .wma`.mp3"; 
done; 
rm -f audiodump.wav

Getting colors to work for ls and vim on Solaris 11

bash
Just some quick notes, for myself and in case someone else ever wants this. In this day and age, I hate having to setup color on terminals ….colors make things very easy to see, quickly. So here are my notes so i don’t have to go spend time figuring it out yet again lol.

in your .profile or .bashrc

export TERM=xtermc
alias ls="/usr/gnu/bin/ls -lah --color=auto"

in your .vimrc

syntax on
set showmatch
set bg=dark
set incsearch
set tabstop=4
set shiftwidth=4
set expandtab
set bs=2

bs=2 makes your backspace erase instead of inserting weird chars
syntax=on will enable color
the rest of it is just my personal settings in vim 🙂

Archlinux – fixing the strange characters in your terminal

bash

Ever get those strange looking little buggers in your console after installing Arch and firing up the terminal ?
Something like this —
[[email protected] ~]$ pstree
init─┬─6*[agetty]
├─crond
├─httpd───11*[httpd]
├─mysqld_safe───mysqld───9*[{mysqld}]
├─sshd─┬─sshd───sshd───bash───su───bash
│ └─sshd───sshd───bash───pstree
├─syslog-ng───syslog-ng
├─udevd───udevd
└─vmtoolsd

Simply add the following to your .bashrc and close your terminal window and open it up again, or source the .bashrc file again.
export LC_ALL=C

[[email protected] ~]$ pstree
init-+-6*[agetty]
|-crond
|-httpd---11*[httpd]
|-mysqld_safe---mysqld---9*[{mysqld}]
|-sshd-+-sshd---sshd---bash---su---bash
| `-sshd---sshd---bash---pstree
|-syslog-ng---syslog-ng
|-udevd---udevd
`-vmtoolsd
[[email protected] ~]$

cronhelp – a syntax reminder for crontab

bash

One of the things an admin needs to know how to do quickly, is setup cronjobs. This is of course done using the crontab -e command. The syntax is hard for some to remember and instead of going to google and searching every time I needed to know the syntax again, years ago I created a small simple shell script called “cronhelp” that I stuck into /usr/local/bin/cronhelp

Then all I would have to do is type “cronhelp” on the command line and my simple help file would display.

#!/bin/bash
crontab ()
{
### cron - Displays a cron help file.
echo " "
echo "Crontab Example/Hints  "
echo "---------------------------------------------------------------"
echo "# +---------------- minute       (0 - 59)"
echo "# |  +------------- hour         (0 - 23)"
echo "# |  |  +---------- day of month (1 - 31)"
echo "# |  |  |  +------- month        (1 - 12)"
echo "# |  |  |  |  +---- day of week  (0 - 7)  (Sunday=0 or 7)"
echo "# |  |  |  |  |"
echo "# *  *  *  *  *  command"
echo "---------------------------------------------------------------"
echo " "
}
crontab
exit 0