Tag: windows

Resolving Windows NetBIOS names in Linux

When accessing computers on a LAN, it's often useful to access them by name instead of IP. This is especially true when dealing with dynamic IP addresses.

In Windows, other Windows computer names are automatically resolved to an IP address. In most Linux distros however, this is not the case (by default).

To resolve Windows NetBIOS names in Linux, you'll need the winbind component of the Samba suite. Winbind allows a UNIX box to become a full member of an NT domain, giving the ability to resolve names from it.

Install winbind via your preferred package manager. For Debian and derivatives, the following should work.

1
apt-get install winbind

Now that winbind is installed, the OS must be configured to use it when looking up hostnames. Open the file /etc/nsswitch.conf and add "wins" to the end of the line starting with "hosts:".

For example, the line in my file now looks like

1
hosts: files dns wins

Save the file and reboot to start the winbindd deamon.

To test if if worked, try pinging a computer on your LAN by name. For example:

1
2
3
4
5
$ ping windows-server
PING windows-server (192.168.0.107) 56(84) bytes of data.
64 bytes from 192.168.0.107: icmp_req=1 ttl=128 time=0.268 ms
64 bytes from 192.168.0.107: icmp_req=2 ttl=128 time=0.604 ms
64 bytes from 192.168.0.107: icmp_req=3 ttl=128 time=0.607 ms

Setting up TortiseHg on Windows

TortiseHg can be a bit of a pain to set up if you don't want to haveĀ peagent running in the background all the time for authentication. This method uses TortisePlink (comes with the install) for authentication, and runs it only when it needs to authenticate.

Generating a public/private key pair

  1. Download PuTTYgen and run it.
  2. Generate the key pair by clicking the generate button.
  3. Optionally, enter a passphrase to protect the private key.
  4. Save the public and private keys somewhere. I prefer to save them as id_rsa.pub and id_rsa.ppk in C:/Users/[username]/.ssh/ but it doesn't really matter.

Setting up TortiseHg

  1. Download TortiseHg and install it.
  2. When installing, make sure that SSH Utils are installed.
  3. When it finishes installing, run the program (it'll be called "TortiseHg Workbench" in the start menu).
  4. Configure the settings as you see fit. This will generate a configuration file at C:/Users/[username]/mercurial.ini.
  5. Close the program and open up mercurial.ini in a text editor.
  6. Under the "[ui]" section (if it doesn't exist, create it) add/edit two entries (adjusting for your own custom settings):
1
2
username = [name] <[email]@[domain]>
ssh = "C:\\Program Files\\TortoiseHg\\TortoisePlink.exe" -i "C:\\Users\\[username]\\.ssh\\id_rsa.ppk"

Now all that's needed is to upload the generated public key to the server(s) you wish to pull from or push to.

When asked, just open the key up in a text editor (make sure it's the public key, NEVER share your private key) and copy-paste the text.

After configuring this, you'll be able to push to repositories on the servers you give your public key to, without having to enter your password every time.


How keyboard media keys work

A recent project of mine involved tearing apart an old keyboard (a Dell Y-UK-DEL1) and using the media keys to make a simple media controller box.

Everything went smoothly with the build, but when I plugged it in, the music media key launched VLC instead of my preferred player, foobar2000. After spending a while in the control panel looking for how to change this behavour and finding nothing, I used Process Explorer to trace the registry key it was using to determine which application to launch.

Turns out, the registry keys in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey store the information regarding what program gets launched when a media key is pressed.

In this location there are a bunch of keys that map button IDs to file associations. This is done by looking up the button ID when the button is pressed, then looking at the contents of the string called "Association" in the button ID's key.

With my keyboard, the music media key maps to button 16. On my system, within the key called "16", there is a string value called "Association". This was set to the ".cda" extension, which is associated with VLC. After changing the ".cda" association to open using foobar2000, whenever I press the music key on my media controller, foobar2000 opens.

© Carey Metcalfe. Built using Pelican. Theme is subtle by Carey Metcalfe. Based on svbhack by Giulio Fidente.