Logging in through SSH without a password

I normally don’t do this for my own personal account, but sometimes you need to use SSH in your scripts. Anyways, here we go:

I will refer to the server that you will access from as ‘Server_Alpha’, this is where the scripts would reside. The server that will be accessed, will be referred to as ‘Server_Beta’. The user wil be named, uhh, ‘User’.
First of all, make sure the user is in both machines. Once that is done, create a folder in your home directory with:

$ mkdir -p /usr/home/User/.ssh

Now to create the key:

$ ssh-keygen -t rsa

You will get a prompt and the output so far should be something like:

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/User/.ssh/id_rsa):

Hit Enter, and it will then prompt for a passphrase. Do not use a passphrase. Just hit the enter button twice.

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

If successful, you will see something like this:

Your identification has been saved in /home/User/.ssh/id_rsa.
Your public key has been saved in /home/User/.ssh/id_rsa.pub.
The key fingerprint is:
2f:c3:ab:02:ea:f3:c6:3e:6a:21:f4:a8:45:e1:65:77 User@Server_Alpha

OK, we are done with Server_Alpha. Let’s move on to Server_Beta.

Make sure that a .ssh directory exists in the home directory and copy id_rsa.pub from Server_Alpha to A file named authorized_keys in the .ssh folder.

You can copy and paste, or use ssh. Just make sure that it is only one line!!

Done!!

Free DNS Tools??

This is more a rant than anything to do with what I normally post, but I just had to post this!!

In case you don’t know, I am a System Administrator for a web design company and I used to work in Tech Support for a hosting company. Since the beginning, I used dnsstuff.com for all my DNS, domain name, email tests. That site was great up until they require you to register. I was so upset that I purchased my own domain name, dnsyard.com, and started to work on my own “dnsstuff”.

Anyway, I periodically check my google ranking (OK, you got me, more like everyhour!!) and I noticed that I am on page 4 for the keyphrase, “free dns tools” (WOO HOO!!). Of course, dnsstuff ranks number one, but I noticed that the number 2 spot has changed. Well it happened to be freednstools.com. I never noticed them, and I’m sure I would have a while ago, but I decided to check them out.

So I did some snooping around. I checked their source code and first of all, noticed that they weren’t using any Keyword Meta Tags, and they rank 2nd, which doesn’t really bother me because the domain name is pretty much the keyphrase (noticed I didn’t link to them at all in this post? haha). Also, their homepage is exactly how dnsstuff used to be, and it included the same exact tools too. So I did a whois for their domain name on their site. And what do you know… The page returned an error.

Warning: fopen(http://www.dnsstuff.com/tools/whois.ch?ip=freednstools.com) [function.fopen]: failed to open stream: HTTP request failed!

WOW!! I guess that’s one way to compete with dnsstuff.com. What more can I say??

BTW, check out my site,  http://dnsyard.com/ (in case you forgot it). I only have a few tools, but I will continue to add to it. Hope you enjoy it.

Done!!

Removing Files That Begin With a Dash “-”

So I wasted about an hour of my life trying to figure out how to remove a filename that begins with a dash, like “-filename”. I tried quotes, backslashes, renaming the file, etc., and I still get the error:

rm: illegal option --

How did I figure this out?? Uhh read the manpage…haha

It looks like there are a few ways to do it. Let’s try to delete -filename

# rm -- -filename
# rm /full/path/to/-filename
# rm ./-filename

Done!!

Error installing GD from php5-extensions using FreeBSD Ports

I’ve run into another problem installing Apache-PHP-MySQL FreeBSD server. While installing php5-extensions, I received an error when it tried to install GD. Here’s the error:

===> Patching for php5-gd-5.2.3
===> Applying FreeBSD patches for php5-gd-5.2.3
===> php5-gd-5.2.3 depends on executable in : phpize - found
===> php5-gd-5.2.3 depends on file: /usr/local/bin/autoconf259 - found
===> php5-gd-5.2.3 depends on file: /usr/local/libdata/xorg/libraries - not found
===> Verifying install for /usr/local/libdata/xorg/libraries in /usr/ports/x11/xorg-libraries
/usr/X11R6 exists, but it is not a symlink. Installation cannot proceed.
This looks like an incompletely removed old version of X. In the current version, /usr/X11R6 must be a symlink if it exists at all.Please read /usr/ports/UPDATING (entry of 20070519) for the procedure to upgrade X.org related ports.
*** Error code 1
Stop in /usr/ports/x11/xorg-libraries.
*** Error code 1

Stop in /usr/ports/graphics/php5-gd.
*** Error code 1

Stop in /usr/ports/lang/php5-extensions.
*** Error code 1

Stop in /usr/ports/lang/php5-extensions.

To fix, all I did was add WITHOUT_X11=yes to my make install line. You can also do a XORG_UPGRADE=yes. Either way works, but the latter will install some x11 items.

Done!!

Search Engine Friendly URL’s Using Mod_Rewrite

Want to make http://domain.com/awesomepage.php?page=4&user_id=badass&action=go look like http://domain.com/awesome/page/4/user/baddass/go ?? To do this, you will need to use mod_rewrite in .htaccess or edit your Virtual Host in httpd.conf.

Here is the code:


Options +FollowSymlinks
RewriteEngine On
RewriteRule ^/awesome/page/([0-9]+)/user/(.+)/(.+)$ /awesomepage.php?page=$1&user_id=$2&action=$3 [NC]

Yes, you will need to create more than one entry per page, but if you plan it out correctly, you will need just one.
That’s all there is to it.

Done!!

What’s My IP Address

Since I have a dynamic IP address at home, I always have to look it up whenever I access anything that is IP restricted at work.

All I do is run a simple code:

echo $_SERVER[REMOTE_ADDR]

Or you can check out my other page, http://topherdotcom.com/scribble/what-is-my-ip-address/ to see your own IP address.

Done!!

Can’t Install mysql50-server Through the Ports?

I’ve been trying to install mysql50-server via ports, but have been getting a checksum error, like this:

=> MD5 Checksum mismatch for mysql-5.0.41.tar.gz.
=> SHA256 Checksum mismatch for mysql-5.0.41.tar.gz.
===> Giving up on fetching files: mysql-5.0.41.tar.gz mysql-5.0.41.tar.gz
Make sure the Makefile and distinfo file (/usr/ports/databases/mysql50-server/distinfo)
are up to date. If you are absolutely sure you want to override this
check, type "make NO_CHECKSUM=yes [other args]".
*** Error code 1

Stop in /usr/ports/databases/mysql50-server.
*** Error code 1

Stop in /usr/ports/databases/mysql50-server.

For an easy fix, all I did was fetch the mysql tar from freebsd.org and place in /usr/ports/distfiles/, intalled again through the ports, and voila!!

Here’s an easy one liner fixer (for the lazy people, like me). Just copy and paste at prompt.

cd /usr/ports/distfiles/ && fetch ftp://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/mysql-5.0.41.tar.gz && cd /usr/ports/databases/mysql50-server/ && make install clean

NOTE: This is all one line.

Done!!