I Prefer Jim Developer James Schubert shares his code and his thoughts.

17Jul/11Off

Hostgator: ssh warns ‘too many authentication failures’

I requested for HostGator to provide ssh access. Since then, I haven't used it. I attempted to ssh into the server today and received the message 'too many authentication failures'.

If you haven't done so already, create a PubKey:

ssh-keygen -t dsa

The ssh-keygen program will ask a few questions such as the key name and the passphrase. Enter whatever you'd like. I'll refer to the file as id_dsa.pub (which is the default name).

Navigate to your .ssh directory:

cd ~/.ssh

Make sure your file exists in this directory.

Now this one-liner does it all:

cat ~/.ssh/id_dsa.pub | ssh -p 2222 -o PubkeyAuthentication=no user@hostname 'cat >> .ssh/authorized_keys'

If you're not familiar with the linux pipe, I will explain a bit. If you understand the above command, you're done. Enjoy.

The first part before the vertical line {the '|' is called a pipe) dumps all of the text (cat) inside the file (~/.ssh/id_dsa.pub) into STDOUT, or the standard output stream. The pipe forces STDOUT from before the pipe to become STDIN (standard input) for the command after the pipe. Normally, on HostGator you would open an ssh session with ssh -p 2222 user@hostname. But, because there is a conflict in either existing keys on your machine or the authentication of those keys on the server, you'll have to add -o PubkeyAuthentication=no. Finally, the command within single quotes at the end dumps the text in STDIN into a file handle (the '>' causes the dumping of this text to redirect STDIN to an existing filehandle, while two of those characters '>>' redirects to a file, creating the file if it doesn't exist).

flattr this!

Tagged as: , , 2 Comments
8Jul/11Off

What happens when I overwrite a DLL (asp.net)?

I post on Stack Overflow a lot. Sometimes, there are really interesting questions like one I answered last year. I had forgotten about it until this week when the answer was accepted. I thought I'd share it on my blog.

The original post is here. Read on for redundancy.

flattr this!

17Jun/11Off

How to move WordPress without breaking web links

WordPress allows you to specify your blog url as, for example, www.ipreferjim.com/site. It also allows you to run the blog from the base of your domain, e.g. www.ipreferjim.com. For the longest time, I didn't mess around with this because I didn't see it as a big deal.

Not long ago, I upgraded linux hosting to Windows deluxe hosting at Godaddy.com. There were so many issues with WordPress under windows (see my previous post). On top of that, performance had never been exactly what I'd expect, and a lot of constraints were blocking me from being productive. So, I switched to hostgator.com.

The problem is that I have years of links to my site in the format:


http://www.ipreferjim.com/site/2011/06/godaddy-url-rewrite-fix-for-directory-without-trailing-slash/

and I now wanted it in the format:


http://www.ipreferjim.com/2011/06/godaddy-url-rewrite-fix-for-directory-without-trailing-slash/

I went about this by following WordPress's guide to giving wordpress its own directory. This went well, then I had to update the .htaccess file to allow /site/wp-admin yet remove /site from all other links.

# BEGIN WordPress

RewriteEngine On
RewriteBase /site
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]

RewriteRule ^/site/wp-admin(.*)$ /site/wp-admin/$1 [L]

# END WordPress

flattr this!

14Jun/11Off

Godaddy URL Rewrite Fix for directory without trailing slash

Not too long ago, I upgraded my godaddy.com hosting account from the linux basic to windows deluxe plans. I did this because I have multiple domains I'd like to host with a single company. I'd never had issues with godaddy's linux hosting.

The problem was that I am a .NET developer and I wanted to start hosting some ASP.NET applications. Since the windows plans are also capable of hosting WordPress, I decided to switch.

My first suggestion to you if you're looking to switch from linux to windows with godaddy: don't.

My second suggestion is that, when you have problems, you don't contact godaddy customer service. After five emails or so, I've determined that the customer service is outsourced and the names in the signature of the email such as "Andrew P" or "Anna K" are fake.

I won't go into it, though. I'll just give you the fix.

Drop a web.config file into the root of your domain's directory like so:

<?xml version="1.0"?>
<configuration>
   <system.webServer>
      <rewrite>
         <rules>
            <rule name="Host Directories Fix" stopProcessing="true">
		        <match url="^(.*)[^/]$" />
		        <conditions logicalGrouping="MatchAny">
		            <add input="{HTTP_HOST}" pattern="^ipreferjim\.com$" />
                 	<add input="{REQUEST_FILENAME}" matchType="IsDirectory" />
		         </conditions>
		        <action type="Redirect" url="http://www.ipreferjim.com/{R:0}/" redirectType="Permanent" />
		    </rule>
         </rules>         
      </rewrite>
   </system.webServer>
</configuration>

On the highlighted lines (9 and 12), you will have to replace my domain name with your own.

The reason this is necessary is because godaddy has IIS 7 configured improperly for serving directories. In fact, here's the initial email I received from them:

Dear Jim,

Thank you for contacting Online Support.  
Upon review of your account it appears you have a Windows hosting account running IIS7.  
The issue you are seeing happens because of the way it is configured with our system.  
I apologize for any inconvenience.

Please let us know if we can assist you in any other way.

Sincerely,

Anna P.
Online Support Team

flattr this!

12Jun/11Off

Can’t login to MySQL as root :(

I was having issues logging into MySQL as root the other day. It took a while to figure things out. Ultimately, I had to follow the steps on two separate posts: http://rimuhosting.com/howto/mysqlinstall.jsp and http://bugs.mysql.com/bug.php?id=22118.

Here are the steps I took:

  1. Stop MySQL:
    /etc/init.d/mysql stop
  2. Edit config:
    sudo vim /etc/my.cnf
  3. Add line to section [mysqld]:
    skip-grant-tables
  4. Start MySQL:
    /etc/init.d/mysql start
  5. Reset Root Password:
    mysql -e &quot;update user set password = old_password('newpassword') where user = 'root'&quot; mysql
  6. Kill MySQL:
    kill `cat /var/run/mysqld/mysqld.pid`
  7. Create an init-file:
    cat ~/mysql-init&lt;&lt;EOF
    UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root'; 
    FLUSH PRIVILEGES;
    GRANT ALL ON *.* TO 'root'@'localhost';
    EOF
    
  8. Run MySQL with the init file:
    mysqld_safe --init-file=~/mysql-init &amp;
  9. Remove the mysql-init file:
    rm ~/mysql-init
  10. Restart MySQL:
    /etc/init.d/mysql restart
  11. Login as root!

Part of this was also taken from the MySQL documentation for resetting a password, however, the contents of the file were changed to match one of the previously mentioned posts. If these steps don't work, please visit the official documentation and give it a try again.

**IMPORTANT**
When you're done following the above steps, please remove 'skip-grant-tables' from my.cnf. Thanks, Ian, for bringing this missed step to my attention!

flattr this!