by Irish on March 21, 2012
I find it’s pretty annoying when you have to go log file spelunking only to find all the timestamps are in UTC. But we can set the timezone of the server so when Rails, cron, scripts, etc run, they output more readable dates.
You can check your current timezone by just running
$ date
Thu Mar 21 18:02:49 MST 2012
Or checking the timezone file at
$ more /etc/timezone
US/Arizona
So to change it just run
$ sudo dpkg-reconfigure tzdata
And follow on screen instructions. Easy.
Also be sure to restart cron as it won’t pick up the timezone change and will still be running on UTC.
$ /etc/init.d/cron stop
$ /etc/init.d/cron start
by Irish on January 27, 2012
Having problems getting ssh to use your public key?
Log on to your server as root using a password. Remember not to log out as root until you have ssh working with your public key or you may inadvertently lock yourself off the box.. which sucks
Double check your sshd_config, I use the following options (note you will have to restart ssh for these changes to take effect):
1 2 3 4 5 6 7 8
| Port 30000 <--- change to a port of your choosing
Protocol 2
PermitRootLogin no
PasswordAuthentication no
UseDNS no
AllowUsers deploy <--- change to whatever users you want
ClientAliveInterval 30
ClientAliveCountMax 4 |
Make sure your public key is in the .ssh/authorized_keys file for the user you plan on logging onto the server as. You can use this super helpful authme bash function.
So let’s say you’ve done all this and YOU STILL CAN’T get it to work. It’s probably because you have incorrect permissions set on the .ssh directory and/or the authorized_keys file. You can check this by looking at the ssh auth log. Depending on your server OS it’s usually either /var/log/auth.log or /var/log/secure . Tail this file and see if you’re getting this message
1
| Authentication refused: bad ownership or modes for directory /home/deploy/.ssh |
Obviously your directory will be different depending on the name of the user you’re trying to ssh on as. But this message is the give away that your permissions are wrong. Change them with the following, assuming your username is “deploy”, otherwise just substitute that part.
$ chmod go-w /home/deploy/
$ chmod 700 /home/deploy/.ssh
$ chmod 600 /home/deploy/.ssh/authorized_keys
Try ssh’ing on again in another terminal window and you should be good. Now it would be safe to log off as root.
by Irish on September 2, 2011
In one of my current project, whenever I ran a rake task that did a net/http request it was causing segmentation faults.
$ bundle exec rake test:task
$ /Users/cirish/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:678: [BUG] Segmentation fault
ruby 1.9.2 (2011-06-30 patchlevel 290) [i686-darwin10.8.0]
And it seems whenever I get a segmentation fault the first place I need to look is at OpenSSL. I’ve had similar problems with seg faults and openssl in the past, namely this OpenSSL Bus Error that I was getting on Ruby 1.8.7.
If you read that post you’ll see this happened because I use MacPorts and have OpenSSL installed through it, in addition to a local OS X version. To get Ruby to be happy, you have to point your Ruby install to the correct version at installation time. So remove the bad install
$ rvm remove ruby-1.9.2
And reinstall
$ rvm install ruby-1.9.2 --with-openssl-dir=/opt/local --with-iconv-dir=$rvm_path/usr
Which I forgot to do with my Ruby 1.9.2 install after upgrading OS X versions. That last bit about iconv isn’t directly related, but I have inconv package installed to RVM, you can read about that here RVM Iconv.
Also, this Phusion blog post REE 1-8-7-2011-03-released mentions problems with OpenSSL and MacPorts. Moral of the story… use HomeBrew? Dunno, but I’ll probably start using it when I upgrade my laptop.