June 17th, 2008 at 11:58 am
Today I did something stupid: I overwrote an SSH public key with a file from a different machine:
CODE:
-
scp id_rsa.pub user@example.org:~/.ssh
Obviously, I wanted to place the Public Key for the account from one machine on the other one to append it to the authorized_keys file of the target account. Unfortunately, I didn't bear in mind that I already had a public key file (id_rsa.pub) in this directory. So I had to re-create the Public Key file from the Private Key. This is quite easy, it appears that the SSH developers already thought of this situation. The following code will restore the Public Key file from the Private Key (example for an RSA key):
CODE:
-
cd ~/.ssh; echo "id_rsa" | ssh-keygen -y> id_rsa.pub 2>/dev/null
0
Tips
authentication, private key, public key, SSH
June 11th, 2008 at 11:03 am
If you have many databases with many write operations, it may be that the table overhead takes a good amount of space. (This is due to the fact that MySQL doesn't free the space of deleted entries.) With "optimizing" the tables, you can free that space.
Save the following script as /usr/local/sbin/optimizealltables.sh, make it chmod 700 (very important!), then replace YOURPASSWORD with your root MySQL password.
CODE:
-
#!/bin/bash
-
-
MYSQL_LOGIN='-u root --password=YOURPASSWORD'
-
-
for db in $(echo "SHOW DATABASES;" | mysql $MYSQL_LOGIN | grep -v -e "Database" -e "information_schema")
-
do
-
TABLES=$(echo "USE $db; SHOW TABLES;" | mysql $MYSQL_LOGIN | grep -v Tables_in_)
-
echo "Switching to database $db"
-
for table in $TABLES
-
do
-
echo -n " * Optimizing table $table ... "
-
echo "USE $db; OPTIMIZE TABLE $table" | mysql $MYSQL_LOGIN >/dev/null
-
echo "done."
-
done
-
done
0
Codebits
MySQL, OPTIMIZE TABLE, shell