Various Quick Tips

Quick tipsJust a bunch of random quick tips, posted together for conciseness
Passwordless SSH'ing as root

When writing the test harness for Snap I needed to setup a few vms which I could ssh into as root automatically, without being prompted for a password. True, I could've setup a ssh key and install that on the vms, but instead for simplicity I wanted to be able to ssh in w/out requiring any credentials (yes insecure, but these VMs are isolated and the test harness makes sure they are shutdown post-invocation).

On Fedora/Ubuntu this is accomplished by:

Now you can ssh root@<ip_address> to login as root w/out a password (obviously use with caution).

Incidentally this is also a means to get a root shell on Ubuntu, which by default does not allow this, requiring the user to run all privileged commands through 'sudo'


I've run into a problem w/ the backlight not resuming normal operation after my laptop has been dock'd. This seems to be a common issue, even on the Linux friendly Lenovo Thinkpad laptops.

After some debugging I was able to resolve this by installing the 'xbacklight' package and running 'xbacklight -set 100'.

C Data Structure Visibility Practices

I've been getting back into C programming (more on this soon). Of course w/ a lower-level language (C is actually a high level language, though usually considered low-level, but I digress) there are many approaches / ways to do things, especially concerning data visibility. Studying the libvirt library header file, I found one useful standard is to:

- define public data structures, eg structures which can be manually instantiated by the user, as you normally would, eg

typedef struct _myData{
} myData;

typedef myDataPtr *myData;

- define private data structures, or data which can only be instantiated by calling one of your methods, w/ forward declerations in the public header, with the private definitions residing in an internal-only header/implementation file, eg

typedef struct _privateData privateData;
typedef privateDataPtr *privateData;

privateDataPtr createPrivateData(...params...);

- define public data structures refering to data managed / manipulated by an external entity, as 'info' structures, (these will often be associated w/ private data in some way) eg

typedef struct _externalDataInfo {
  ...fields about data managed elsewhere...
} externalDataInfo;

typedef externalDataInfoPtr *externalDataInfo;

externalDataInfoPtr getExternalDataInfo(privateDataPtr private_data);

Per Host SSH Key

Many thanks to jkeating for this pro-tip. To set which ssh key to use on a per-host basis, simply create a ~/.ssh/config file (chmod'd to 600) containing the following contents:

Host <hostname>
IdentityFile <path-to-ssh-key>

Also optionally specify 'User <username>' to not have to prefix your remote username to the hostname when logging in w/ a username different than your local one.

Thats all folks!