Thursday, 9 September 2004

How to make your important files stand out from the others while using Gnome in linux.

While playing around in gnome, I came across a niffy way by which you can mark a particular file or folder in gnome file manager (this works on files on the gnome desktop too) to stand out from the others. This is made possible by marking your file or folder with an emblem. That is right, by using an emblem, you can mark your important files and folders using cute icons to which you associate special meaning. For example, you can associate an emblem named "important" to a file which holds your important data and another folder which holds fun stuff can be given the emblem named "cool" and so on.

This can be achieved as follows :

While in gnome window manager,Select the file or folder (in nautilus) to which an emblem has to be applied. Then right click keeping the mouse pointer on the selected file / folder. Then a menu pops up in which you select the "Properties" command. Then a window pops up showing the permissions that the file or folder has. There is a tab in the window named emblems. Click on it and you are shown a good collection of icons having different names like cool, important, draft, mail and so on. Make your selection and press OK button. Voila! your file sports a niffy emblem which makes it easier for you to identify from the other files or folders of similar nature. This I discovered in Gnome 2.4. But I guess it can be obtained in more recent Gnome 2.6/2.8 too (but I have tried it only in gnome 2.4).

You can also add your own set of emblems. To do that first create small icons (PNG) ideally 32x32 pixel format and then copy them into your ~/.nautilus/emblems/ directory. You can get a great set of icons at Tigert.gimp.org site.





The Menu when you right click on a file or folder. Posted by Hello







The emblem dialog Posted by Hello







The file showing the tagged emblem Posted by Hello

Sunday, 5 September 2004

SSH - Secure SHell

SSH is a Secure SHell which can be used in the place of telnet to connect to a remote machine. The advantage of using ssh over telnet is that communication and data transfer between the local machine and the remote machine occurs in a secure encrypted tunnel. So no one will be able to snoop on your data.These are a few tips in using this program.

Connect to remotehost and tunnel all X traffic over the encrypted connection.

To see how this works, run the command as follows :

$ ssh -X remotehost
...and then run xeyes when you get your shell prompt on the other machine. Notice how it automatically displays on your own X server.

Tunnelling an entire X Session over SSH

This is the method used to tunnel an entire X session from a remote host.

$ ssh -X remotehost

$ gdmXnest &

$ export DISPLAY=:20 // DISPLAY=:20 should be the same thing that gdmXnest just printed.

$ gnome-session
Note that if you aren't on the same LAN, you'll probably want to use a lightweight window manager like fluxbox instead of heavy desktops like gnome and kde.

Copying an entire directory to a remote host using SSH

Let us say you want to copy entire contents of the current directory to the directory tree /tmp/dir on the remotehost. This can be done with a combination of tar and ssh as follows:

$ tar cf . | ssh remotehost "cd /tmp/dir ; tar xf -"
Finally, some helpful information for troubleshooting SSH connections and their keys.

If you are having problems connecting to an SSH server , then the steps given below should help you in tracking down your problem as well as prevent future problems. Follow the steps given below while testing your connection after every step.

  • Check your logs.
    # less /var/log/secure
    This will contain the logs related to the ssh authentication. It is also a good idea to turn on debugging in /etc/ssh/sshd_config to better clarify the problem. Add the following line to /etc/ssh/sshd_config file.
    LogLevel DEBUG3
  • After making changes to the sshd_config file, restart the service.
    # service sshd restart
    You can now view the connection attempts in the console by issuing:
    # tail -f /var/log/secure
    To exit, just do a [Control + C]
  • Verify the keypair.
    # ssh-keygen -y
    This can be used to generate the public key for a known private key. By comparing the output of this command to what you believe to be the public key, you can determine if the key's match. For Example:
    [user@linux .ssh]$ ssh-keygen -y

    Enter file in which the key is (/home/user/.ssh/id_rsa): /home/user/.ssh/id_dsa

    [KEY Here......................................

    .

    .................................. ]

    [user@linux .ssh]$ cat /home/user/.ssh/id_dsa.pub

    [KEY Here......................................

    .

    .

    .................................. ]

    [user@linux .ssh]$
    Verify that most of the numbers look ok. The odds of two keys being off by only a few numbers are very small. The error would be blatant. If the key's do not match (or do not exist), generate new key's (See the end of this post).
  • Check your permissions. SSH is very picky about permissions, so be sure that your user has the correct rights to the files. The most important files are located in ~/.ssh . Do these as root. This assumes that your user's name is user, so you should change the name accordingly.
    # chown user:user /home/user/.ssh

    # chmod 700 /home/user/.ssh

    # chown user:user /home/user/.ssh/*

    # chmod 640 /home/user/.ssh/*

    // The following files may not exist

    # chmod 600 /home/user/.ssh/identity

    # chmod 600 /home/user/.ssh/id_dsa

    # chmod 600 /home/user/.ssh/id_rsa
  • Check the Settings in sshd_config .
    # vi /etc/ssh/sshd_config
    This file contains the settings used by the SSH Daemon. Any line preceded by a "#" is commented out and shows the default setting. For Example:
    # Port 22
    Means that no change has been made from the default, and the default is Port 22 for SSH connections. Look through the file for the following settings, and note their values. The defaults are listed here.
    #AuthorizedKeysFile .ssh/authorized_keys2

    #PasswordAuthentication yes
    For troubleshooting purposes you should comment out the above lines. Also look for:
    AllowUsers
    If that line is present, make sure that your user's name is listed. (If its not listed, you can add it for extra security.) For Example:
    AllowUsers user user1 user2
    Remember to restart the service:
    # service sshd restart
These steps should help you get an SSH session up and running using key authentication. You should be able to track any further problems from the log file, but if you follow these directions, most problems you could face should be mitigated.

Generating New Keys

Note: This is to be done as a normal user. I'm using DSA keypairs for an example.

$ ssh-keygen -t DSA
This will create two files: ~/.ssh/id_dsa and ~/.ssh/id_dsa.pub . You can optionally create a passphrase for the keys, as an added level of security.

Copy the public key to your authorized_keys2 file.

$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys2
Copy the id_dsa to your client machine and change its permissions to read/write for the user and none for the group and others.

$ mv id_dsa .ssh/id_dsa

$ chmod 600 .ssh/id_dsa


Friday, 3 September 2004

How to use windows fonts in Mozilla (linux)

In order to do that, you needed to copy the fonts you use for Windows XP Pro to Linux. Here are the steps to get fonts over to Linux and how to activated them:
1. If you don't have a /usr/share/fonts/TrueType directory, create one.
# mkdir /usr/share/fonts/TrueType
# cd /usr/share/fonts/TrueType

2. Make sure that all the font files you're copying have lower-case extensions, so if you have files like font.TTF, rename that to font.ttf
3. Copy the fonts to /usr/share/fonts/TrueType
4. Change into that directory:
# copy  /mnt/C:\/windows/fonts/*.ttf   /usr/share/fonts/TrueType/. # cd  /usr/share/fonts/TrueType 

5. Issue the following commands to build the necessary fonts.scale and fonts.dir:
# ttmkfdir -o fonts.scale
# mkfontdir

6. This should have now created the fonts.scale and fonts.dir files
7. Now go to you /etc/X11 directory so that you can add the new font directory to the search path of your X server by adding it to the fonts section of XF86Config

8. Edit XF86Config - Go to the "Files" section and add the FontPath there, mine looks like the following after editing:
RgbPath "/usr/X11R6/lib/X11/rgb"
FontPath "unix/:7100"
FontPath "/usr/share/fonts/TrueType"

9. Now for the Mozilla part! Go to the directory you installed Mozilla in, located at /usr/local/mozilla. Change into /usr/lib/mozilla-1.4/defaults/pref. Note your mozilla may be installed somewhere else. In redhat, try
# rpm -ql mozilla grep unix.js 
to get the path where your unix.js file resides.
10. Backup the unix.js preference file so that you can get back to it if anything screws up:
11. cp unix.js unix.js.bak
12. Edit the unix.js file and look for the TrueType section and change it to look like the following snippet:

// TrueType
pref("font.FreeType2.enable", true);
pref("font.freetype2.shared-library", "libfreetype.so.6");
// if
libfreetype was built without hinting compiled in
// it is best to leave
hinting off
pref("font.FreeType2.autohinted", false);
pref("font.FreeType2.unhinted", false);
// below a certian pixel size
anti-aliased fonts produce poor results
pref("font.antialias.min", ;
pref("font.embedded_bitmaps.max", 1000000);
pref("font.scale.tt_bitmap.dark_text.min", 0);
pref("font.scale.tt_bitmap.dark_text.gain", "0.7");
// sample prefs for
TrueType font dirs
pref("font.directory.truetype.1",
"/usr/share/fonts/TrueType");
pref("font.directory.truetype.2", "/usr/X11R6/lib/X11/fonts/TTF");
//pref("font.directory.truetype.3",
"/u/sam/tt_font3");
pref("font.FreeType2.printing", true);

Now you'll enjoy a MUCH clearer veiw of websites you visit!