Hacker’s Diary

Avatar

My Knowledge Database

[KB] The remote session was disconnected

Problem:

Often after upgrading client machines to XP Service Pack 3, I get problem while connecting to Terminal Server. The connection is refused with following error: “The remote session was disconnected because the terminal server client access licence stored on this computer has been modified.”

Solution:

1. Click Start, click Run, type Regedit.exe, and then click OK.
2. Locate the following key in the registry:
HKEY_LOCAL_MACHINE\Software\Microsoft\MSLicensing\Store\
3. Delete the TS CAL key, probably LICENSE001.

NOTE: Typically, LICENSE000 is the license for the operating system and LICENSE001 is the TS CAL. To verify this information, check to see whether the ProductID value is present; this value indicates the license for the operating system.
4. When the client attempts to reconnect to the Terminal server, it will request a new TS CAL.

If deleting the LICENSE000 or LICENSE00x key to troubleshoot connection failures does not let a client connect to a Terminal server, back up the whole MSLICENSING key, and then delete the whole key. Try to connect to a Terminal server. This causes the generation of a new hardware ID. This enables the client to request a new license, and to successfully connect. The MSLICENSING key and all subkeys are recreated.

Bookmark and Share

[HowTo] Debian killall: command not found

Last week our admin from Saint Petersburg’s office installed Debian on a new router-box. While playing and setting everything up, I noticed that there is no “killall” command. What to do?

Alternatively you can use “pkill”, like:

pkill apache

In my opinion works even better that killall. If you like the old favorite killall, just install the psmisc package:

apt-get install psmisc

Note: this packages also includes command like “pstree”, very useful.

Bookmark and Share

[HowTo] Find files that contain a given string

If you are searching in current folder, sometimes command like:

cat * | grep -i “string” *

will print the filename and a line that matched the string. But this will not “search” in subfolders, and will not work on some Linux distros.

The right (my) way would be:

find /path/to/folder -type f -exec grep “string” {} \; -print

This will print a line that matched the string, and filename on the next line.

Bookmark and Share

[HowTo] Change a hostname after Linux installation

I usually set hostname during Linux installation, but many people don’t. Then without a knowledge it could take some time to change it correctly.

Doing so:

hostname newhostname

will only change hostname temporary, after system reboot it will change back to what it was specified during installation.

So the right (my) way of changing hostname:

  • Some linux systems keep hostname record in /etc/sysconfig/network

    HOSTNAME=localhost.localdomain
  • Debian systems /etc/hostname
    localhost.localdomain
  • Additionally hostname is kept in /etc/sysctl.conf
    kernel.domainname = localdomain (usually uncommented)
    kernel.hostname = localhost

And at the end, don’t forget to add hostname to /etc/hosts file like this:

127.0.0.1       newhostname.localdomain       newhostname

or

127.0.0.1       newhostname

Otherwise services like Apache, Squid and many others won’t run correctly or won’t run at all if they can’t resolve the hostname either by hosts file or DNS server.

Bookmark and Share

[HowTo] Virtual Machines on Debian using XEN

This solution assumes you have already installed Debian Linux with minimum base system.

This solution is made for amd64 system. But others should be the same, just find the correct package for you system.

Setup

First install SSH, so it will be a lot easier to copy/paste commands in console

apt-get install ssh

Remove packages we don’t need

apt-get remove exim4 exim4-base lpr nfs-common portmap pidentd pcmcia-cs pppoe pppoeconf ppp pppconfig
apt-get install screen debootstrap iproute python python-twisted-core python-twisted-conch bridge-utils

XEN related packages

apt-get install xen-linux-system-2.6.18-6-xen-amd64
apt-get install xen-tools

If you wish to use XFS file system, you also need to install xfsprogs

apt-get install xfsprogs

Creating Virtual Machines

The best way of creating up virtual machines is using hard drives LVM volume, thus way you can easly increase partition size of partition where VM is.

Creating virtual machine using LVM volume vs0, and ext3 filesystem. VM will be running minimum base install of Debian Linux

xen-create-image –hostname=vm1.hackersdiary.com –size=4Gb –swap=512Mb –ide \
–ip=10.0.0.119 –netmask=255.255.255.0 –gateway=10.0.0.1 –force \
–lvm=vs0 –memory=512Mb –arch=amd64 –fs=ext3 –kernel=/boot/vmlinuz-2.6.18-6-xen-amd64 \
–debootstrap –dist=etch –mirror=http://ftp.ee.debian.org/debian/ –passwd \
–initrd=/boot/initrd.img-2.6.18-6-xen-amd64

This will create a 4Gb root partition, and 512Mb swap for VM. After the installation of base system, you will be required to input root password for your newly created VM.

To create XFS filesystem on VM, replace the –fs=ext3 with –fs=xfs
To use image files instead of LVM volumes replace –lvm=vs0 with –dir=/vm/images

Make VM to start automatically on boot

ln -s /etc/xen/vm1.hackersdiary.com.cfg /etc/xen/auto

Starting up VM manually

xm create -c /etc/xen/vm1.hackersdiary.com.cfg

To leave VM’s shell, type CTRL+] if you are at the console, or CTRL+5 if you’re connected to main debian using ssh

Shutting down VM

xm shutdown vm1.hackersdiary.com

Also awailable commands

xm reboot vm1.hackersdiary.com
xm list


How to increase VM’s partition size (Only if using LVM)

XFS Filesystem

lvextend -L+10G /dev/vs0/vm1.hackersdiary.com-disk
xm shutdown vm1.hackersdiary.com
mount /dev/vs0/vm1.hackersdiary.com-disk /vm/base
xfs_growfs /vm/base
umount /vm/base
xm create -c /etc/xen/vm1.hackersdiary.com.cfg

EXT3 Filesystem

lvextend -L+10G /dev/vs0/vm1.hackersdiary.com-disk
xm shutdown vm1.hackersdiary.com
resize2fs /dev/vs0/vm1.hackersdiary.com-disk
e2fsck -f /dev/vs0/vm1.hackersdiary.com-disk
xm create -c /etc/xen/vm1.hackersdiary.com.cfg

Comments? Problems? You’re welcome.

Bookmark and Share

How to hide files from Apache’s directory index

To prevent certain files from appearing in directory indexes, in case this needs to remain enabled. This is particularly useful for non html files (or raw files not parsed by apache and returned as a html to the browser), for example: php include files, libraries (that will not have the extension php), or log files, or any other file that you might want to prevent the users to easily see in the browser.

Use the apache directive IndexIgnore to hide the list of files:

IndexIgnore .htaccess
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
IndexIgnore *.inc

Bookmark and Share

How to access Samba shares from Windows Vista

The quick fix to this Samba Vista issue is to switch Windows Vista LAN authentication level.

Instructions below:

1. Open the Run command and type “secpol.msc”.
2. Press “continue” when prompted by Vista.
3. Click on “Local Policies” –> “Security Options”
4. Navigate to the policy “Network Security: LAN Manager authentication level” and open it.
5. By default Windows Vista sets the policy to “NTVLM2 responses only”. Change this to “LM and NTLM – use NTLMV2 session security if negotiated”.

Bookmark and Share

,

Protect yourself

FREE Online Scanner - Detect more than 3 million threats

Some useful ads

Before you go

Going so soon? May these links be a guide to web enlightenment. Schwing!