Here’s a nice trick to zero out a file that’s in use:
cat /dev/null > /path/to/file
The reason for this is that if you simply remove a file that’s in use by some process on the system, the disk space will not be released until the process closes the file or terminates.
By cating /dev/null and redirecting it to the file, it magically guts out the contents of the file while keeping the same inode. The process that has that file open will continue writing to it without knowing any better, and the disk space will be released.
Update: A simple test using python to keep a file handle open showed me that while the cat trick zeros out the file, python keeps track of the last position written to within the file. The next time the python process writes to the file, you’ll end up with null bytes at the beginning of the file.
Typically ssh keys go in a user’s home directory in
.ssh/authorized_keys2. But, not on an OpenWRT router. Instead, the file is at
To force a new DHCP lease on OS X you can use the following:
sudo ipconfig set en0 BOOTP; sleep 1; sudo ipconfig set en0 DHCP
It basically tells the ethernet device to use BOOTP, which gets rid of the current IP, then tells it to use DHCP a second later, which makes it request one again.
The device, above
en0, should be changed to whatever device is to be updated.
In a standard sized shell, the
dpkg command truncates the package name. That’s not very useful if you’re trying to remove a package and need the full name. A way around this is to use the COLUMNS environment variable, for example:
COLUMNS=120 dpkg -l 'postgre*'
Dropbear creates an ssh key in binary. To print out the public key, use:
dropbearkey -t <keytype> -y -f <filepath>
$ dropbearkey -t dss -y -f .ssh/dropbear.key
Public key portion is:
ssh-dss AAAAB3NzaC1kc3MAAACBAPl[...]== some_key
Fingerprint: md5 75:d7:d0:2b:1d:56:4c:42:06:cc:00:9a:53:ba:f2:d7
Using the openssl command, it’s possible to connect to the secure service and dump its certificate chain.
Accessing secure services with command line apps such as
ldapsearch, etc. fail if the server’s certificate is not trusted. Most of the time they won’t be due to the command not having a certificate store to check against. Using the
openssl command, it’s possible to connect to the secure service and dump out its certificate. For example, the following will dump out the server’s certificate:
openssl s_client -connect example.com:443
You can also get the CA certificate by adding the
openssl s_client -showcerts -connect example.com:443