Password Generation

So we have all been at the point where we are registered on seemingly millions of sites, and instead of using strong passwords like we should, we get lazy and don’t. Yeah, you know what I’m talking about.

I use a Greasemonkey script (found here) called Password Composer (you can read all about it on that link). Now, this script is an absolute godsend really. But there are some shortcomings..sortof. Not with the script itself, but more with the convenience and implementation. For example, I use my mac regularly, so its totally cool to be running Greasemonkey and my custom hacks. But what about the times I need to quickly check my mail on a random work computer? or the library? or any public computer??

I pop open Firefox and go to login to my email… Then I remember that my email is conveniently locked down by an MD5 encrypted master password to keep me idiots out.

I setup a web based form for these dire times. Check it out here.

You can get the offline version here.

View installed packages [Linux]

I wanted to save a file of all the packages I had installed on my Ubuntu server in case i wanted to swap hard drives and/or reinstall the OS. Found this, works like a charm :)

dpkg --get-selections > /home/name/installedpkgs.txt

Ubuntu Sendmail Error

Arrg, sendmail!

I’ve been having some terrible problems with Ubuntu dropping the network connection (by either reverting from static back to DHCP or it stopped sending packets) on network restart. Each time it would come up with an error:

tank~# /etc/init.d/networking restart
Setting up IP spoofing protection: rp_filter.
Enabling TCP/IP SYN cookies...done.
Enabling packet forwarding...done.
Reconfiguring network interfaces...ifup: interface lo already configured
addr=192.168.1.102, name=
Updating databases ...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Creating /etc/mail/databases...
Updating Makefile ...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Creating /etc/mail/Makefile...
Updating sendmail.cf ...
*** ERROR: FEATURE() should be before MAILER()
*** ERROR: FEATURE() should be before MAILER()
*** MAILER(`local') must appear after FEATURE(`allmasquerade')*** ERROR: FEATURE() should be before MAILER()
*** MAILER(`local') must appear after FEATURE(`always_add_domain')*** ERROR: FEATURE() should be before MAILER()
*** ERROR: FEATURE() should be before MAILER()
*** ERROR: FEATURE() should be before MAILER()
*** ERROR: FEATURE() should be before MAILER()
*** FEATURE(smrsh) must occur before MAILER(local)
*** ERROR: MAILER(local) already included
*** ERROR: MAILER(smtp) already included
Updating access_db ...
Updating ALIAS_FILE ...
The following file(s) have changed:
/etc/mail/sendmail.cf
** ** You should issue `/etc/init.d/sendmail reload` ** **
Mail Transport Agent: sendmail is not running
done.

Nasty, right? Yeah.

The Fix

Get rid of it, and install Postfix instead.

sudo apt-get remove sendmail
sudo apt-get autoremove

but the remove actually leaves 2 files which still leaves you with an error!

The Real Fix

remove these:
/etc/network/if-up.d/sendmail
/etc/network/if-down.d/sendmail

I’ve noticed its been much much more stable since sendmail has been gone.

Adding Directories to PATH variable [OSX]

About the Use of Dot-Slash in Commands

The combination of a dot followed directly by a forward slash (./) is often used to precede commands in Linux and other Unix-like operating systems. Although this requirement can seem confusing and even tedious to new users, it exists for good reason and can be useful to understand.

Commands in Unix-like operating systems are either built-ins or executables. The former (e.g., alias, cd, echo, kill, ls and pwd) are part of the shell that is currently running, and thus the shell can always locate them. In contrast, the shell needs help in finding the latter, which can be divided into compiled programs and shell scripts. A compiled program is a program whose source code (i.e., its original, human-readable form) has been converted through the use of a compiler into an executable file (i.e., a ready-to-run form).

A shell is a program that provides the traditional, text-only user interface for Unix-like operating systems. Its primary function is to read commands that are typed in at the command line (i.e., in a text-only mode) and then execute (i.e., run) them. A shell script is a short program that is written in a shell programming language and interpreted (i.e., converted into runnable form) by a shell process.

When some text is typed into a shell and then the ENTER key is pressed, the shell assumes that it is a command. The shell immediately checks to see if the first string (i.e., sequence of characters) in that text is a built-in command or the absolute path (i.e., location relative to the root directory) to an executable.

If it is neither of these, the shell will search the directories listed in that users’ PATH environmental variable for a file with that name. PATH (all upper case letters) tells the shell which directories to search for commands in response to commands issued by the user.

If the command is found, it will be executed, assuming that there are no other problems. If it is not found, an error message, such as command not found, will be returned.

Most users work most of the time in their home directory and subdirectories thereof because of convenience and for safety reasons. However, by default such directories are not included in the user’s PATH variable. Thus when the user creates a script or compiles a program in one of those directories and attempts to run it by merely typing in its name, an error message will be returned.

However, this problem can be easily overcome by typing a dot and slash in front of the command name. This is merely an abbreviated way to inform the shell that the absolute path of that file is the current directory (i.e., the directory in which the user is currently working). In Unix-like operating systems, a single dot is used to represent the current directory in a path (i.e., the location of a file or directory in the filesystem), including those used in commands. Likewise, forward slashes are used to separate directories and files in paths.

Files in the current directory can be accessed for reading and writing by merely entering the command name (e.g., cat or vi) followed by the name of the file. That is, no absolute path is necessary. However, when execution is desired, either an absolute path (or its dot slash equivalent) or the inclusion of the directory containing the command’s executable file in the PATH variable is necessary. This is a built-in safety mechanism.

A user could eliminate the need to precede commands by a dot slash by appending a single dot to the PATH variable, because this would tell the shell to also search the current directory. However, this is generally not advisable on safety and security grounds. For example, were the user to inadvertently create a shell script with the same name as a standard command, the shell could execute the former instead of the latter, thereby causing the system to malfunction, or worse.1

A better alternative if one wants to eliminate the need to precede commands by a dot slash is to create a special directory for the executable files of such commands, and then add this directory to the PATH variable. For example, a user named bob could create a directory named bin in his home directory (i.e., /home/bob/bin/) for this purpose.

Now, to add the path…

Open the Terminal application. It can be found in the Utilities directory inside the Applications directory.

echo 'export PATH=YOURPATHHERE:$PATH' >> ~/.profile

Close and reopen Terminal. Your session will now use the added path.

Passwordless SSH Login

On the Local Box at the prompt:

ssh-keygen -t dsa
scp ~/.ssh/id_dsa.pub name@192.168.1.106:/home/name/
ssh username@remote

Now you will be on the Remote Box. Do the following:

mkdir /home/name/.ssh
cat ~/id_dsa.pub >> ~/.ssh/authorized_keys
chown -R demo:demo /home/demo/.ssh
chmod 700 /home/demo/.ssh
chmod 600 /home/demo/.ssh/authorized_keys
exit

Back to the Local Box

ssh-add ~/.ssh/id_dsa

Thats it! you should now be able to SSH to your server without being prompted for a pass.

A (very) easy alternative — 1 line

cat .ssh/id_dsa.pub | ssh name@192.168.1.106 'cat >> .ssh/authorized_keys'

Things to remember:

  • Public key goes on the remote box, Private key stays on local box
  • You only have to do ssh-keygen once. Ever. After that you can append your public key to any server.