Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Shared on Facebook

Shop at Amazon

Ad

OSXDaily on Facebook

Search Tips & Tricks

How to Set Up a Password-less SSH Login

May 25, 2012 - Leave a Comment

Set up password-less SSH logins

Setting up passwordless SSH logins is a great way to speed up connections to regularly accessed remote Macs and unix boxes. Because OS X doesn’t include the ssh-copy-id command, you will have to use cat or scp to copy over your ssh key. This is how to set everything up, it only takes a minute or so.

First, on the local machine you will want to generate a secure SSH key:

ssh-keygen

Walk through the key generator and set a password, the key file by default goes into ~/.ssh/id_rsa

Next, you need to copy the generated key to the remote server you want to setup passwordless logins with, this is easily done with the following command string but you can use scp if you’d prefer:

cat ~/.ssh/id_dsa.pub | ssh user@remotehost 'cat >> ~/.ssh/authorized_keys'

This command takes the generated SSH key from the local machine, connects to the remote host via SSH, and then uses cat to append the key file to the remote users authorized key list. Because this connects with SSH to the remote machine you will need to enter the password to use this command.

Finally, confirm that you can now login to the remote SSH server without a password:

ssh user@remotehost.com

Assuming initial setup went as intended, you will connect to the remote machine without having to log in. You can shorten the connection steps even further by creating an alias in bash_profile so that you are only required to type a short command to immediately connect to the specified remote server.

There are some obvious potential security risks with using ssh without a password, the best way to mitigate that is to lock down the client machine with lock screens for screen savers and sleep and boot passwords, all of which you should be utilizing anyway.

Check Hard Drive Health of a Mac with Disk Utility

May 24, 2012 - 5 Comments

Check Hard Drive health of a Mac with OS X Disk Utility

It’s a good idea to check the hard drive health of a Mac as part of a periodic maintenance routine. Doing this is extremely easy with Disk Utility, here’s how to do it and what to do if you encounter any issues:

  1. Launch Disk Utility, found within the /Applications/Utilities folder
  2. Select the Mac hard drive from the left side menu and click on the “First Aid” tab
  3. Click on “Verify Disk” in the lower right corner and let it run

You will find the window populating with messages about the drives health, messages that indicate things are fine appear in black, messages that indicate something is wrong appears in red. For the vast majority of users it will look something like this, finalizing with a message of “The partition map appears to be OK”, indicating no errors:

Verifying partition map for “APPLE Media”
Checking prerequisites
Checking the partition list
Checking for an EFI system partition
Checking the EFI system partition’s size
Checking the EFI system partition’s file system
Checking all HFS data partition loader spaces
Checking Core Storage Physical Volume partitions
The partition map appears to be OK

If you do see a red message saying something along the lines of “Error: This disk needs to be repaired” and it’s your boot drive, you’ll find the “Repair Disk” button is inaccessible. In this case all you need to do is reboot into the Recovery HD partition and run Repair Disk from there, here’s how to do that in OS X Lion and Mountain Lion:

Before proceeding it’s a good idea to backup your drive quickly with Time Machine.

  1. Reboot the Mac and hold down Command+R (hold own Option key on some Macs)
  2. Select “Recovery HD” from the boot menu
  3. Choose “Disk Utility” from the Mac OS X Utilities screen
  4. Click the hard drive that reported the error, click the “First Aid” tab, and now click on “Repair Disk”

After Repair Disk has ran successfully, you are free to boot OS X as normal and the drives issues should be resolved.

A few final notes: relying on a hard drive being healthy is not an alternative to having backups, you need to backup your Mac with regularity using Time Machine or some other method if you choose. Hard drives fail, it’s a fact of computing life. It’s also important to note Disk Utility isn’t a 100% conclusive test suite to determine drive health, and if you hear weird sounds coming out of the hard drive it’s probably a good time to head down to Apple and prepare for a drive swap because that drive is likely going to croak soon.

Use Airplane Mode with Wi-Fi & Bluetooth Enabled on an iPhone or iPad

May 24, 2012 - 4 Comments

Airplane mode with Wi-Fi turned on

If you want to use an iPhone or iPad during a plane flight, you’re supposed to turn Airplane mode on to disable the built-in wireless communication aspects of the device. Airplane mode disables cellular and 3G/4g connectivity, GPS, wi-fi, and Bluetooth capabilities, but how are you supposed to use inflight wi-fi service if everything is turned off? The solution is to enable Airplane mode as usual, but then manually turn on Wi-Fi or Bluetooth separately on the iOS device:

  • Launch Settings and flip “Airplane Mode” to “ON”
  • Tap on “Wi-Fi” and flip the switch to “ON”, join the wireless network as usual
  • For Bluetooth use, within Settings tap on “General” and then tap “Bluetooth” to enable separately

Either choice will not reenable the cellular modem or connection, typically keeping you within the realm of acceptable behavior for most flights. You’ll probably want to check with the specific airline before doing this, but chances are if they offer inflight wireless service then it’s acceptable behavior.

Outside of flying, using Airplane mode but turning on wi-fi is an easy way to temporarily turn an iPhone into an iPod touch, letting you use wifi networks but avoid any potentially expensive voice or data roaming charges.

Instantly See All Keyboard Shortcuts for Mac Apps with CheatSheet

May 23, 2012 - 26 Comments

CheatSheet views all keyboard shortcuts for Mac applications

There are so many keyboard shortcuts throughout Mac OS X and it’s myriad of third party apps that it’s easy to forget them or get lost trying to memorize the sea of keystrokes for each app. This is where CheatSheet will make your life easier, it’s a tiny free application that sits in the background waiting to be summoned from any app to instantly show all keyboard shortcuts for that application.

After you’ve downloaded CheatSheet, place it in /Applications/ folder and the launch the app. Now from any application, hold down the Command key for a few seconds to summon the “Cheat Sheet” list of all keyboard shortcuts for that app. This allows you to quickly see even the most obscure shortcuts that would otherwise be buried deep within a submenu somewhere.

Here’s a quick video showing CheatSheet in use with Google Chrome and TextEdit:

Quick troubleshooting tips: if some apps aren’t responding to the hotkey, either relaunch those apps or try releasing and holding Command again and it should activate. Also if you’ve forgotten the meaning of Mac keyboard symbols it may be a good time to review those really quickly.

My only complaint about CheatSheet is that since it runs in the background you have to use something like Activity Monitor to easily quit out of it. Having an optional menu item to summon the cheat sheet for the active application, give you some control over basic settings like response time, and having a quick way to quit CheatSheet would be a nice touch, but this is a free app that is very useful as is so we really can’t complain too much.

Whether you’re a longtime Mac user or completely new to the platform, you are practically guaranteed to find CheatSheet useful. Get it now and thank me later.

Figure Out Which Direction You Are Facing With iPhone & Maps

May 23, 2012 - 4 Comments

Find which way you are facing using an iPhone and Maps

The iPhone has the Compass app to help show you which direction you are facing, but if you’re in an area with cellular reception a much more practical and useful approach is to use the Maps app. This lets you see which direction you are facing on a map of the area, so you can quickly see landmarks or whatever else you are looking for.

This will work on any iPhone, iPad, or iPod touch with internet connectivity, though it’s likely most useful in the 3G/4G enabled models for obvious reasons.

  • Launch Maps app and tap the Arrow icon to locate where you are
  • When Maps has centered on your location, tap the Arrow icon again

The arrow icon will switch to show what looks like a flashlight beam coming out of the point, this orientates the Maps app based on which way you are facing. Use this feature to either quickly find North, South, East, and West, or if you’re in the middle of the nowhere you can use it to find your way to the nearest road or familiar landmark that you find on Google Maps.

Use Maps app as a compass to find which direction you are facing from an iPhone or iPad

The primary weakness with this method is that iOS and Google Maps does not store or cache maps data locally on the device. This means if you’re out of cell range and you use the compass feature of Maps, you’ll just have a direction pointed out on a blank grid, unable to find any meaningful landmarks or points on the Map. This prevents an iOS device from serving as a true GPS replacement for serious outdoor uses, but if you’re in a bind it can be better than nothing.

This feature will not work if location services is disabled, a feature some people turn off because it can reduce the life of a battery charge on some iOS devices.

How to Create a Disk Image of an Entire Mac Hard Drive

May 23, 2012 - 3 Comments

Make a disk image backup of a Mac hard drive

You can image a Mac hard drive with the help of a free third party utility called Carbon Copy Cloner. The resulting image will be saved as the familiar .dmg format, this has a number of potential uses ranging from creating a drive clone for backup purposes, restoring the image elsewhere as a bootable backup, or even for deploying the same Mac OS X installation on multiple machines.

The process below will describe how to create an exact image replica of a selected Mac hard drive. If the hard drive being imaged is very large the resulting disk image is also going to be large, be sure to have adequate space to support the image or consider saving it to another location.

  1. Get Carbon Copy Cloner free from Bombich and copy it to the /Applications/ folder
  2. Launch Carbon Copy Cloner and pull down the “Source” menu, selecting “Macintosh HD” or whatever the Mac hard disk is named
  3. Pull down the “Destination” menu and choose “New Disk Image”
  4. Create a disk image of a Mac hard drive

  5. Give the disk image a name and select a destination, if you don’t have the local storage capacity for such a large disk image be sure to choose an external or network drive as the image destination
  6. Pull down the “Image Format” menu and choose “Read-only disk image”, this saves the image as the familiar DMG format
  7. Set the disk image as DMG format

  8. Click “OK”
  9. Back at the main CCC menu, choose “Clone” to create the exact replica of the drive as a disk image file

The process of creating the disk image can take a very long time depending several factors, including the speed of the Mac, the size of the disk being imaged, and the destination of the image itself. Don’t be surprised if it takes quite a while to create the backup file.

When finished you’ll have an exact replica of the Macs hard drive in the form of a .dmg image file. If you intend on using the image on a Windows PC, you may want to convert it to an .iso first.

You’ll notice we didn’t choose to create an encrypted image, that is an option you can use if it fits your use case, though creating encrypted drive images takes even longer and they also have the potential of issues when restoring down the road.

Bring Color Icons Back to the Mac OS X Finder Easily with SideEffects

May 22, 2012 - 12 Comments

Color Sidebar icons made easy with SideEffects

If you want color icons back in your OS X Finder window sidebar but don’t want to deal with the existing procedures of manually installing SIMBL and the other components, grab SideEffects instead. SideEffects is a simple package that includes the three necessary components to add color back to Finder sidebar icons; SIMBL, ColorfulSidebar, and RelaunchFinder, all wrapped into a single easy to use installer to shorten the process considerably. Gone will be the drab grayscale icons, welcome back the color.

SideEffects works with OS X 10.7.4 or later including Mountain Lion (supposedly).

For those wondering what is being installed and where it’s going, the files added by SideEffects are as follows:

SIMBL
/Library/ScriptingAdditions

ColorfulSidebar
/Library/Application Support/SIMBL/Plugins

RelaunchFinder
/Applications/RelaunchFinder.app

Also note that RelaunchFinder.app is also added to the active users login items so that the color icons take effect on each reboot or login.

Thanks to Simon for the tip, similar icon colorization is available for iTunes too.

Install wget in Mac OS X Without Homebrew or MacPorts

May 22, 2012 - 9 Comments

Install wget in Mac OS X

The command line tool wget lets you retrieve a group of files from FTP and HTTP protocols, it’s a very useful utility for web developers and powerusers to have around because it lets you do things like perform quick and dirty site backups and even mirror websites locally.

This approach is going to build and install wget in OS X from source, this means you’ll need Xcode and the Unix dev tools (free @ Mac App Store) installed, but it has the benefit of eliminating the need of a package manager like Homebrew or MacPorts.

Assuming you have Xcode and the command line tools installed, launch Terminal and enter the following commands:

First, use curl to download the latest wget source:
curl -O http://ftp.gnu.org/gnu/wget/wget-1.13.4.tar.gz

Next we use tar to uncompress the files you just downloaded:
tar -xzf wget-1.13.4.tar.gz

Use cd to change to the directory:
cd wget-1.13.4

Configure with the appropriate –with-ssl flag to prevent a “GNUTLS not available” error:
./configure --with-ssl=openssl

Build the source:
make

Install wget, it ends up in /usr/local/bin/:
sudo make install

Confirm everything worked by running wget:
wget --help

Clean up by removing wget source files when finished:
cd .. && rm -rf wget*

You’re all set, enjoy wget in Mac OS X.

Turn a Python, Perl, Ruby, or Shell Script Into a Self Contained Application for Mac OS X

May 22, 2012 - 2 Comments

Script turned into a self contained Mac OS X app

Platypus is an excellent utility that lets you turn virtually any script into a self-contained Mac OS X application. Free and remarkably simple to use, Platypus will support just about any shell script, Perl, Python, PHP, Ruby, Tcl, AppleScript, Expect, and even other scripting languages.

Using the app is easy, drag and drop a script onto the application, give it a name, assign an Output type (progress bar, script output, webkit view, etc), set drag & drop support or not, and adjust a few other variables as necessary. When done configuring, click “Create” to build a self-contained application that holds the script inside. The resulting application is completely portable and runs independently, letting you use the app on your own Mac or elsewhere, allowing for even novice users to perform complex tasks and run scripts that would otherwise be beyond their skill level to even execute.

The possibilities are practically endless so let your creativity go wild, because it’s Playtpus that makes apps like the troubleshooting tool Consultant’s Canary possible.

For a basic yet practical use case, build an app to perform a necessary repetitive task and add it to a users Login Items or put it in the Dock or Launchpad for easy novice access. It certainly beats trying to explain to someone how to run a bash script!

Quickly Minimize Windows in Mac OS X with a Keyboard Shortcut or Double-Click

May 21, 2012 - 10 Comments

Faster methods to minimize windows in Mac OS X

Virtually everyone knows you can click the yellow pill button in the upper left corner of a window to minimize a window in Mac OS X, but there are actually a few other ways minimize windows faster than that. The first is my preferred method which is a quick keystroke, and the other lets you double-click anywhere to send a window hiding.

The Minimize Window Keyboard Shortcut: Command+M

By far the fastest way to minimize windows is the Command+M keystroke, which works anywhere with the currently active window. You can modify it by adding an Option+H as well to minimize and hide everything including the currently active window with Command+Option+H+M

Double-Clicking Title Bars to Minimize Windows in OS X

Longtime Mac users should be familiar with this feature which lets you double-click anywhere in the titlebar to minimize a window. To do this in OS X, you’ll have to enable the feature in preferences:

  • Open System Preferences and click on “General”
  • Look under the scroll bar section and check the box next to “Double-click a window’s title bar to minimize”

Double Click a Window Title Bar to Minimize it in Mac OS X

This feature has been around in various forms since the early days of Mac OS 7, 8, and 9, long before OS X came along.