Tuesday, November 20, 2007

WinXP Examples

Add a new Group in WinXP

Local Users and Groups manages users and groups of users for your computer. You can create new users and groups, add users to groups, remove users from groups, disable user and group accounts, and reset passwords.
Start Menu -> Programs -> Administrative Tools -> Computer Management -> System Tools -> Local Users and Groups -> Groups
Or
Right click on My Computer -> Manage -> System Tools -> Local Users and Groups -> Groups

New Example
Here

Sunday, November 11, 2007

Cygwin sshd RSA host key has just been changed

When you get the following errors from SSHD, you'll never be able to connect to your SSHD server.

bash$ ssh your_id@your_server_ip
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
xx:d3:xx:61:58:xx:fc:ee:1a:xx:da:9a:xx:42:xx:d1.
Please contact your system administrator.
Add correct host key in /home/your_id/.ssh/known_hosts to get rid of this message.
Offending key in /home/your_id/.ssh/known_hosts:52
RSA host key for your_server_ip has changed and you have requested strict checking.
Host key verification failed.
bash$

To fix the problem:
1. Modify .ssh/known_hosts: Remove the line with your_server_ip.
your_server_ip ssh-rsa AAAAB3NzaC1yc2EasdfawAAAIExxVkLHiIpIKDAasdfaxQwUgJ90asdfjoejcxxxkxlKineYdiVb/iZxxxj3yxQf4q2CR8UNuaXJLgmU6G6IrCHtuv0N+xxxyw1cmlRxxx5QEMuYawJmiq87ukcW3zasdfadsffrheF6e7CFwUnD747xxxxxxYN5asdfbcasdfashg5XeymM=
2. bash$ ssh your_id@your_server_ip to try to reconnect to your sshd server.

Thursday, November 8, 2007

Install cygwin cron via cron-config script

The following was the steps I took to install cygwin cron in WinXP SP2. Note that the value of CYGWIN should be exactly "ntsec", you can't enter "netsec tty". Also, the /etc/passwd and /etc/group should be set to readable to everyone.

bash$ pwd
/usr/bin

bash$ cron-config
Do you want to install the cron daemon as a service? (yes/no) yes
Enter the value of CYGWIN for the daemon: [ntsec smbntsec] ntsec tty
ERROR: Only "[no]ntsec" "[no]smbntsec" "[no]traverse" allowed.
Enter the value of CYGWIN for the daemon: [ntsec smbntsec] ntsec

The service can run either as yourself or under a privileged account.
Running as yourself allows better access to network drives,
but does not allow to run the crontab of other users.
Do you want to the cron daemon to run as yourself? (yes/no) yes

Please enter the password for user 'your_userid': your_password
Reenter: your_password
Running cron_diagnose ...
The file /etc/passwd is not readable by all.
Please run 'chmod +r /etc/passwd'.

The file /etc/group is not readable by all.
Please run 'chmod +r /etc/group'.

There may be serious issues with your environment.
You should look into them and run this script again.
Do you want to continue anyway? (yes/no) no
bash$
bash$ chmod +r /etc/passwd
bash$ chmod +r /etc/group
bash$
bash$ cron-config
Cron is already installed as a service under account your_domain\your_userid.
Do you want to remove or reinstall it? (yes/no) yes
OK. The cron service was removed.

Do you want to install the cron daemon as a service? (yes/no) yes
Enter the value of CYGWIN for the daemon: [ntsec smbntsec] ntsec

The service can run either as yourself or under a privileged account.
Running as yourself allows better access to network drives,
but does not allow to run the crontab of other users.
Do you want to the cron daemon to run as yourself? (yes/no) yes

Please enter the password for user 'your_userid': your_password
Reenter: your_password
Running cron_diagnose ...
WARNING: You do not currently have a crontab file.

... no problem found.

Do you want to start the cron daemon as a service now? (yes/no) yes
OK. The cron daemon is now running.

In case of problem, examine the log file for cron,
/var/log/cron.log, and the Windows event log (using /usr/bin/cronevents)
for information about the problem cron is having.

Examine also any cron.log file in the HOME directory
(or the file specified in MAILTO) and cron related files in /tmp.

If you cannot fix the problem, then report it to cygwin@cygwin.com.
Please run the script /usr/bin/cronbug and ATTACH its output
(the file cronbug.txt) to your e-mail.

Useful <PRE> tag

If you have a text file or a code block and you want to put quickly online and keep it's text format with spaces or tabs. You don't have to go through all the bother of adding and spacing it all out correctly. The easiest solution is to use the <pre></pre> tag which maintains a text format - line breaks and tabs.

#!/usr/bin/bash

if [ ! $# == 2 ]; then
echo "Usage: $0 <dbuser> <dbpassword>"
exit
fi

You still have to convert the following characters before put the code in <pre></pre> though:

& : &amp; [ & a m p ; a m p ; ]
< : &lt; [ & a m p ; l t ; ]
> : &gt; [ & a m p ; g t ; ]

Thursday, November 1, 2007

CVS Examples

Adding files to a directory
$ mkdir -p foo/bar
$ cp ~/backend.c foo/bar/backend.c
$ cvs add foo
$ cvs add foo/bar
$ cvs add foo/bar/backend.c
$ cvs add backend.c
$ cvs commit -m "Early version. Not yet compilable." backend.c

Removing files
$ cd test
$ rm *.c
$ cvs remove
cvs remove: Removing .
cvs remove: scheduling a.c for removal
cvs remove: scheduling b.c for removal
cvs remove: use 'cvs commit' to remove these files permanently
$ cvs ci -m "Removed unneeded files"
cvs commit: Examining .
cvs commit: Committing .

Remove directories
Removing directory equals to removing files under the directory you want it to be removed. When you checkout the source with a -P option, cvs will remove the empty directory automatically.

Rename a file
$ mv old new
$ cvs remove old
$ cvs add new
$ cvs commit -m "Renamed old to new" old new