OpenBSD set up default boot time by modifying boot.conf file

Posted on in Categories last updated September 19, 2007

Q. I’m using OpenBSD as VPS os (guest os) under VMWARE server. However OpenBSD pauses for a few seconds to give me a chance to provide parameters to the kernel at boot> prompt. I’d like to force boot loader to wait for 30 seconds instead of default timeout. How do I setup bootloader timeout?

A. OpenBSD uses boot program. The main purpose of this program is to load the system kernel while dealing with the downfalls of the PC BIOS architecture. This program acts as an enhanced boot monitor for PC systems, pro viding a common interface for the kernel to start from. By default, boot attempts to load the kernel executable /bsd. If it fails to find the kernel and no alternative kernel image has been specified, the system will be unable to boot.

/etc/boot.conf file and timeout parameter

/etc/boot.conf is configuration file for bootloader. Open file using text editor:
$ sudo vi /etc/boot.conf
Append / modify timeout parameter as follows:
set timeout 30
Save and close the file. Above line set the 30 second pause at boot-time.

How to backup the remote files in Linux / UNIX

Posted on in Categories , , , , , , , , , , , , last updated August 24, 2007

Q. How do I make remote backups under Linux? I’ve CentOS 5 Linux server located in remote data center and I’d like to backup it to local or another server?

A. Both Linux / UNIX come with handy tools to make secure remote backups. You can use tool called rsync for automating remote backups of your Linux, UNIX, Windows server, Mac OS X and BSD systems. rsync is a program with many more options and uses the rsync remote-update protocol to greatly speed up file transfers when the destination file is being updated.

Task: Copy files / backup files from remote Linux server

Let us say you would like to backup files from remote server called and directory called /home/vivek to local directory called /backup, type the command as follows on local system:
$ rsync -avz -e ssh [email protected]:/home/vivek/ /backup
You need to supply password for vivek user.

Task: Exclude files from backup

You can also skip few files from backup. Let us say you don’t want to backup all C source code file, enter:
$ rsync --exclude '*.cpp' -avz -e ssh [email protected]:/home/vivek/ /backup

Task: Automatic backup using a shell script

SSH always prompts for a password. To automate process via a shell script you need to remove password using SSH key i.e. generate passphraseless keys, enter (type at local system):
$ ssh-keygen -t dsa
When asked for to enter passphrase, just press [ENTER] key twice. Now copy public key to remote server:
$ scp ~/.ssh/ [email protected]:.ssh/authorized_keys
Now you can login without a password. For more information see – howto setup SSH with DSA public key authentication and RSA key authentication for password less login.

Now create a simple shell script as follows:
$ vi
Append code:
rsync --exclude '*.cpp' --exclude '*.log' -avz -e ssh [email protected]:/home/vivek/ /backup

Setup executable permission using chmod command:
$ chmod +x
Use cron to command to backup remote server:
$ crontab -e
Make a backup everyday:
@daily /path/to/
Save and close the file.

BASH Shell setup filename tab-completion case insensitive

Posted on in Categories , , last updated August 16, 2007

Q. I’m using BASH shell filename tab completion feature to complete file names and other stuff. However default tab-completion in bash case-sensitive. It cannot show me /tmp/Y* or /tmp/Y* files. How do I force filename tab-completion in bash case insensitive?

A. According to bash man page completion-ignore-case set to Off. If set to On, readline performs filename matching and completion in a case-insensitive fashion. Readline has variables that can be used to further customize its behavior. A variable may be set in the /etc/inputrc file with a statement of the form. So all you have to do is type following command:
$ set completion-ignore-case on

You need to add set completion-ignore-case on to /etc/inputrc command:
vi /etc/inputrc
Append text as follows:
set completion-ignore-case on
Close and save the file. For more information read bash man page.

Linux: Openssh (ssh server) deny root user access

Posted on in Categories , , , , , , , , last updated August 2, 2007

Q. How do I block access to root user over ssh session?

A.. sshd (OpenSSH Daemon) is the daemon program for ssh. Server side ssh configuration is defined in /etc/ssh/sshd_config file.

You need to use DenyUsers option to block access to root user.

This option can be followed by a list of user name patterns, separated by spaces. Login is disallowed for user names that match one of the patterns. Only user names are valid; a numerical user ID is not recognized. By default, login is allowed for all users. If the pattern takes the form [email protected] then USER and HOST are separately checked, restricting logins to particular users from particular hosts.

Open /etc/ssh/sshd_config file

Use vi command:
# vi /etc/ssh/sshd_config

Deny root user access

Append or modify as follows to block root user:
DenyUsers root

If you want to block additional user just append names to DenyUsers
DenyUsers root, user2, user3

Save and close the file. Restart sshd service:
#/etc/init.d/sshd restart