Using udev to trigger events in example

Find device (this works only with input devices):

Use the name to find system path of the device:

Make a test run:

Look data that is specific to device you want to customize. ID_TYPE=hid is too general, but perhaps ID_VENDOR_ID or ID_MODEL_ID. Sometime there is some tip about device type like ID_INPUT_TOUCHPAD=1. If the data seems too general, it may be better to attach to parent device, run the command again without the last “event” part:

Still, try to find something as close to the end of the chain as possible. Another way worth of trying is to run udevadm info:

Finding the right filter rules seems to be always most difficult for me… Create a new file in /etc/udev/rules.d starting with 2-digit number (this is rule’s priority, I suggest a large one to keep the rule close to the end of the chain). My rules for detecting a Apple Bluetooth keyboard and  a touchpad are:

So I’m using Bluetooth address for keyboard and ID_INPUT_TOUCHPAD for the touchpad. When it is added to system, a script “send-command” will be run. After editing the file, save it and run the udevadm test again:

Check the run command is there. If not, change the rules and try again. If it worked, run one last command to inform the udev daemon about the changes:

That’s it. Now it’s up to you to write the event handlers.

Using SSH without password

Using SSH often to login to remote systems? Sick of entering your password every few minutes? Consider logging using public key authentication.

What is this?

This authentication method uses 2 keys: private and public. Let’s use example:

  • S is some remote server
  • C is your laptop

The public key is put on server. It can be shared with anyone, it is of no use to anyone except the owner of the private key.

The private key is kept in safe place on laptop. During authentication server S verifies whether the secret key from C matches the public key on S. If so, user is allowed to log in. It is important to remember, keeping the private key secret is just as important as guarding your password.

Preparation

Simpler than it used to be… To generate the new key pair:

and follow defaults. There will be a warning if the key already exists. For simplicity don’t specify a password (I will write how to use a password protected key without having to type too much another time).

Now, to copy the public key to remote sever run:

Enter the password once more, and try:

Congratulations! And remember to protect the key!