Archive for February 3rd, 2011

find/xargs/grep tricks

Because xargs will die if you have an unescaped quote, but using -0 screws everything up if you’re reading a list of files:

sed s/\'/\\\\\'/|cut -d \: -f 1|xargs -i rm "{}"

The sed pattern will put the escape character in front of any single quotes so that xargs doesn’t screw up.

Using md5sum to compare files, use grep -v FAILED to quickly get a list of files that passed the md5 check.

Feed it into xargs to delete the files:

grep -v FAILED|sed s/\'/\\\\\'/|cut -d \: -f 1|xargs -i rm "{}"


No Comments

Allowing password-less SSH logins

Because I don’t care too much about what happens to my test servers, I’ve been setting up password-less SSH logins. Using a Linux system to login is trivial, because it’s a simple matter of doing


on the system that will be connecting to the remote server, and just hitting enter until the key is generated.

After that, it’s a simple

scp > host:/home/kyl191/.ssh

followed by

cat .ssh/ >> .ssh/authorized_keys2

once you login to the remote server.

For Windows, it works with putty, but you have to use puttygen as well as convert the key it generates into a different form, so it’s more involved. But still works. ^^

Also, add the line echo “key_contents” > /home/$user/.ssh/authorized_keys2 to the kickstart file to automatically set every future installed system up to work with your password-less login.

No Comments