View posts for Tag: "Howto"

Windows server lockout

Since there are not only unix-based servers out there in the web, I sometimes also encounter Windows servers which I have to maintain.

Usually, you connect to a Windows server using Microsoft’s “Remote Desktop Connection” (RDC) client. If you’re not running a terminal server, the number of allowed sessions on the server is limited to two sessions at a time.

Unfortunately a session isn’t ended and closed if you close your RDC client window, but only if you log off, i.e. by clicking on “Start” -> “Log Off”. So if you just close your RDC window without to log yourself really off, there’s a good chance that you lock yourself out from the server and thus get the following message “Terminal Server Has Exceeded the Maximum Number of Allowed Connections”.

If you have access to your server, you can easily log on to the server on-site and remove all “dead” sessions, but if your server is somewhere on this planet where you can’t just go over to, you should be served by using the following command:

C:\>mstsc -v:your_server_name_or_ip -admin

This command gives you access to a special session, namely the session 0 and you should be able to log in as “Administrator” and remove the dead sessions.

This two sessions at a time restriction is really annoying and it gets even more annoying if other people also use the server and don’t log off correctly. Having such stupid problems is probably one reason why many people get mad a Microsoft and their products. It’s simply a licensing issue you don’t have on Linux and *BSD systems ;-) .

Leave a Comment

Upgrading Debian Etch to Lenny

On last Saturday Debian 5.0 “Lenny” has been released as stable. This probably means a lot of updating work for many administrators. I was updating a couple of servers during the last days. Due to Debian’s APT system it’s a pretty easy process.

Step 1: Edit your /etc/apt/sources.list. Replace every occurrence of “etch” (I assume you’re updating from Debian “Etch”) with “lenny”. Your sources.list should now be looking roughly like that:

deb http://ftp.de.debian.org/debian/ stable main
deb-src http://ftp.de.debian.org/debian/ stable main

deb http://security.debian.org/ stable/updates main contrib
deb-src http://security.debian.org/ stable/updates main contrib

Step 2: Simply run apt-get updateand you should probably get something like this:

srv:~# apt-get update
Get:1 http://ftp.de.debian.org stable Release.gpg [386B]
Hit http://ftp.de.debian.org stable Release                                    
Get:2 http://security.debian.org stable/updates Release.gpg [189B]
Hit http://security.debian.org stable/updates Release
...
Hit http://security.debian.org stable/updates/main Sources
Hit http://security.debian.org stable/updates/contrib Sources
Fetched 2B in 0s (15B/s)
Reading package lists... Done
W: There is no public key available for the following key IDs:
4D270D06F42584E6
W: You may want to run apt-get update to correct these problems

Apparently, this means you need to get the public key for 4D270D06F42584E6. ;-) This can easily be done with the following commands.

srv:~# gpg --keyserver wwwkeys.eu.pgp.net --recv-keys 4D270D06F42584E6
gpg: directory `/root/.gnupg' created
gpg: can't open `/gnupg/options.skel': No such file or directory
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: requesting key F42584E6 from hkp server wwwkeys.eu.pgp.net
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key F42584E6: public key "Lenny Stable Release Key <debian-release@lists.debian.org>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1
srv:~# apt-key add /root/.gnupg/pubring.gpg
OK

Please note that the key ID and though the public key needed on your system can differ from this one.

Step 3 Finally, you can rerun the package-list update and run the actual upgrade.

srv:~# apt-get update
srv:~# apt-get dist-upgrade

Depending on your machine’s capacity and your internet connection speed the upgrade can take from about 15 minutes to some hours. The avarege time my updates took was 30 minutes. After that you can reboot your freshly upgraded system with the new kernel and you’re done.

1 Comment

How to download videos from YouTube

YouTube is the world’s #1 source for more or less funny or interesting videos. Unfortunately YouTube does not offer any options to download the videos from their site. YouTube even hides the direct links to their video resources. Even though it’s quite easy to find a download link for the real .flv videos:

  • Just go to the site where your desired video is i.e. http://de.youtube.com/watch?v=-xEzGIuY7kw .
  • View the source code of the site and search for a section that starts with “swfArgs”.
  • From this section you need the values for “video_id” and “t” (i.e. “video_id”: “dsfaAfdaAfs” and “t”: “sdfkljasldfjlkasflshdfjaiosjjsknfjkhJhjdf”)
  • With these values you should be able to call “http://www.youtube.com/get_video.php?video_id=<your video_id value>&t=<your t vlaue>” and to download your desired video.

I’ve made a little shell script for Linux and Mac that does all the searching stuff for me and that returns the url to the video source.

#!/bin/sh

if [ $1 == "" ]; then echo -e "$0: No URL specified\nUsage: $0 <url>\n"; exit 1; fi

which curl > /dev/null
if [ "$?" == 0 ]; then GET_COMMAND=curl
else
  which wget > /dev/null
  if [ "$?" == 0 ]; then echo "Didn't find curl nor wget. Exiting."; exit 1;
  else
    GET_COMMAND=wget -O ytf| cat ytf; rm ytf;
  fi
fi

# Use GNU version of sed on Darwin/OS X
if [ `uname -s` == "Darwin" ]; then SED=gsed;
else SED=sed; fi

RELEVANT_DATA=`$GET_COMMAND $1 | grep 'swfArgs' | $SED 's/,/\n/g'`
VIDEO_ID=`echo "$RELEVANT_DATA" | grep 'video_id' | $SED 's/"//g' | $SED 's/ //g' | $SED 's/:/=/g'`
T=`echo "$RELEVANT_DATA" | grep 't"' | $SED 's/"//g' | $SED 's/ //g' | $SED 's/:/=/g'`

LINK="http://www.youtube.com/get_video.php?$VIDEO_ID&$T"

if [ "$VIDEO_ID" != "" ] && [ "$T" != "" ]; then echo $LINK; exit 0;
else echo "Couldn't retrieve the needed data from the specified URL."; exit 1;
fi

To run the script correctly the GNU version of “sed” is needed.

Leave a Comment