Wednesday, July 1, 2009

SSH’ing Into Your Mac

I use SSH a lot, it stands for Secure Shell and its main purpose is to connect to other computers, or servers, over a secure connection which you can use to manage the remote computer. For a general overview I recommend reading this Wikipedia article. For this article you do need to be a little tech savvy with Terminal, but if you are way from your computer, or you want to manage another computer this is a very useful technique.

The first step, which you must do, is enable this process in your Firewall. Took me ages to work out while I couldn’t do this on my own Mac. Go to System Preferences > Sharing and check Remote Login. This will open port 22 on your computer and allow SSH to be active.


This should be done on the computer you want to log into. For the purpose of this tutorial you can do it on your own computer, remember to switch it off when you have finished for security purposes. Under the Green icon there will be an address. This combines your ISP Internet address, which is given to you by your ISP, in my case it is part of my Uni address, this will be unique to you. For example it will be a unique identifier, such as a MAC address or account name, on your ISP network, it will then be preceded by your ISP web address. For the most part you don’t need to understand how this address is built. You just need to know what it is. The first part of the address is the user name, for the purpose of most maintenance a normal account will suffice, if you want to do some really high level stuff an administrators account can be used.

You can now log into the remote (or your Mac). Open terminal and type:

ssh user@ISP.address.com

This will start the connection process. If it immediately says connection refused make sure you have enabled SSH as mentioned above. If it says couldn’t connect on port XXX, add the following.

shh -p22 user@ISP.address.com

This will force your SSH connection to run on port 22, instead of a different port. If you, or someone else, has used SSH before it may have been bound to a different port. This will correct this problem.

The first login will ask you to accept and RSA key. This is a method to make sure the two computer are who they say they are. Since you know this accept the key by typing yes and hitting return. This is a security method to keep the connection secure, more information about this process can be found here.

The very final step is to type the password which belongs to the user name. This is the remote Mac’s login password, not your own, my friend who I tried to teach this concept too, didn’t grasp this step for a long while and confusion ensured. Once you have done this, the connection will be secured and you can happily run commands on their computer.

At this point you can run any Terminal command, which is useful to sort out problems with file and folder errors and problems relating to settings. You can also use it to monitor the health of the remote computer by running a process such as ‘top’. The Terminal window, at this point, is exactly the same as one you would use on your own computer. It just happens that the result run on a different computer and are forwarded to you.

When you have finished your session, type exit and the SSH session will finish.

Although this is a tech savvy process and solutions such as screen sharing are more useful to people who do not know how to use Terminal, it is a great technique to learn. You can use it on any Mac, Linux or Unix computer, this method is exactly the same. It is also very low bandwidth, with screen sharing your are sending a lot of data, this technique sends text. Text has a very low data rate, as a result can run on a dial up connection. This sort of process can be used to administer a server over a home network, or to make sure a remote Mac (such as your Grandparents) is still operating fine.

There is a lot more topics on how to use SSH on your Mac. I recommend search the internet for how to find out more, if you are interested on using this technique more.


Friday, June 19, 2009

MacBook Pro 13-inch teardown reveals "unimaginative" SD Card slot

A dissection of Apple's first 13-inch MacBook Pro shows the company may have run out of real estate to create a slot that would completely conceal SD cards but also points to certain do-it-yourself upgrades being near-trivial jobs for prospective owners.

The undisputed teardown experts at iFixit have just completed their step-by-step illustrated disassembly of the latest member of the MacBook Pro family, in which they note that the system's new SD card slot "is rather unimaginative" given that "half the card hangs out of the side of the computer."

"Apple couldn't free up enough space for a slot that would make the card completely captive," representatives for upgrade solutions provider told AppleInsider.

As with the MacBook Air and 17-inch MacBook Pro, removing the battery is simple enough that it can be done quickly, likely to allowing technicians to swap out batteries at Apple retail stores in a matter of minutes. All that's needed is a small Phillips screwdriver to open the case and a tri-wing screwdriver to remove the battery.

It's also noted that the mid wall dividing the MacBook Pro is now attached to the top case, unlike in previous models where it was was held in by four Phillips screws. iFixit believes this may be a move on Apple's part to help out its do-it-yourself customers.

"Aside from a couple of visual cues found outside, a casual user would not be able to discern if this was a [unibody] MacBook or MacBook Pro," the firm added. "Most screw layouts and brackets are identical to the old [unibody] MacBook."

Also discovered was a slightly heavier battery at 360 grams (compared to 302 g for the old one). However, it offers 60 Watt-hours of power, compared to the lighter battery's 45 W-h. And given that its connectors, size, and shape are different from the battery in the 13-inch unibody MacBook, the new battery isn't interchangeable with last year's models.




Apple's Mac OS X 10.5.8 to fine tune service technologies

The next, and potentially final, upgrade to Apple's Mac OS X 10.5 Leopard operating system will address loose ends in the software's underlying service technologies with a particular focus on networking and syncing.

Just two betas of the Mac OS X 10.5.8 Update have made their way into developers' hands thus far, the first of which was labeled build 9L12 and arrived for an extremely limited group of testers early last week. That distribution was quickly followed by the release of build 9L14 to all registered Mac OS X developers this past weekend.

Unlike Mac OS X 10.5.7, which addressed roughly two dozen system components and applications, Mac OS X 10.5.8's focus appears more narrow from the onset. People familiar with the update say Apple has asked developers to concentrate their evaluation efforts on just a dozen key technologies, only two of which represent forward-facing applications: Automator and iCal.

The remainder of the update addresses underlying service technologies that include 802.1x wireless protocols, Apple Filing Protocol, AirPort, Bluetooth, graphics drivers, iDisk syncing, networking, Spotlight indexing, Sync Services, and USB.

Similarly, many of the roughly two-dozen code corrections already baked into the first two pre-release builds also target underlying networking and syncing technologies. For example, Apple has reportedly made note of fixes to AFP and TimeMachine syncing, iCal time and calendar syncing, execution of startup items on Network home folders, and problems with DHCP client and 802.1x integration.



New Mac owners wrestling issues with their DisplayPort to DVI/VGA adapters should also see improvements with the release of Mac OS X 10.5.8, though Apple has reportedly failed to provide any color on the specific issues being addressed. Those users experiencing issues where their Mac inexplicably fails to go to sleep a second time around will also reportedly see relief to their problems.

Mac OS X Snow Leopard gives heads-up for near-death MacBook batteries

While the immediate charge on a Mac notebook's battery has been available for years, Mac OS X Snow Leopard now tells owners when their batteries are nearing the end of their useful lifespans.

Those familiar with the WWDC build of the operating system upgrade note that clicking the battery icon in the menu bar now shows a new, one-word "battery condition" summary in addition to the energy for the current charge and the power source.

When the battery has been used often enough that it 's losing capacity, the icon is overlaid with an exclamation mark warning and the battery condition changes to "poor" -- both signs that the pack is due to be replaced. While not every condition is known, Snow Leopard presumably reports varying degrees of battery status when the pack has only been moderately used or is like new.

The addition partly replaces third-party utilities that sometimes provide a more detailed estimate. Apple hasn't documented the reasons behind the change, but the most logical explanation is simply that the company's decision to seal in most notebook batteries makes it more important to have an early notice that a battery is near failing. A replacement of the sort is easy for technicians but, without the option of swapping batteries in the field, not trivial for end users.



Apple has lately been paying closer attention to battery life on all its devices and with iPhone OS 3.0 will add a numerical percentage to the iPhone's previously icon-only battery indicator.

Wednesday, June 17, 2009

Save non-savable PDF files

Occasionally one has to use an annoying PDF that one can't re-save, but can only print. My sister had this situation dealing with some obnoxious state-run Microsoft system that didn't allow the user to save a completed form, only to print it from a browser. The individual administering the system apparently flipped the wrong bit, as last year, the form could be saved.

Here's a workaround, various versions of which can allow you to save the PDF:

1. Turn off the print queue for the printer by going to Printer Setup Utility.
2. Print the file, but don't reactivate the printer -- choose the Add to Queue option.
3. Go into the terminal and su to root. (If you haven't enabled root, use sudo -s to start a root shell.)
4. Type cd /var/spool/cups, then identify the file you just printed. Do this by matching the queued file's time stamp to the time you printed the file (ls -l; the file of interest should be at the bottom).
5. Copy (don't move) that file out of the spool folder: cp filename ~/Desktop. I don't know what a move (mv) will do to the print system.
6. Type cd ~/Desktop to move to your user's Desktop folder.
7. Type chown myaccount:myaccount filename to make sure the Finder in your user space will play nicely with the file.
8. Peek inside the file and determine whether it's a postscript or PDF file -- you can drop it on TextEdit to see its contents. If it's a postscript file, rename the file to filename.ps. If it's a PDF file, rename it to filename.pdf.
9. Confirm the above by dropping the file on Preview. If the file is a postscript file, you can then save it as a PDF file from Preview.

Mac OS X 10.5: Take and upload screenshots via Automator

I often take screenshots and upload them for my friends to see -- especially while working on web projects etc. So I created an Automator workflow that does this automagically!

First the workflow snaps the whole screen and saves it to the desktop. Then a bash script is run wich uses ftp to upload the image to the webserver. It then takes the URL of the image and copies it to the clipboard. Lastly it notifies you of the upload via Growl. It has no error handling or anything. This is my first workflow and bash script ever, but it works for me. In Automator, create the following steps in a new blank workflow:
  1. Utilities » Take Screenshot. Use these settings:
    • Type: Full Screen, or whatever you prefer.
    • Select Main Monitor Only and/or Timed as you desire.
    • Set the Save To pop-up menu so that it saves to a file named tmpScreen.png on your Desktop.
  2. Utilities » Run Shell Script. Set Shell to /bin/bash and Pass Input to to stdin. Enter the following code, noting the lines you need to edit:
    #!/bin/sh
    # Author: Simon Ljungberg @ www.nimnim.se

    # Edit the 5 lines below to fit your configuration
    # URL will be copied to your clipboard!
    HOST='yourftphost'
    USER='yourusername'
    PASSWD='yourpassword'
    REMOTEFILE='pathtoremotefile(including filename)'
    URL='http://yourdomain.com/screens/screenshot.png'

    # If you change this you need to change the rm-line too.
    # For some reason (I'm new at this) I couldn't get the file
    # to disappear when using the variable...
    LOCALFILE='~/Desktop/tmpScreen.png'

    ftp -n $HOST <
  3. If you have Growl installed, add Utilities » Show Growl Notification. Give it a Title ("Done!") and Description ("Your screenshot has been uploaded") so you'll see a message after the upload is completed.
Alternatively, you could download the script from my server, and then just change the variables in the shell script section of the workflow.

To make this work, you need a web server with FTP access, and note that your username and password are stored in the script. Works for me in 10.5.7; I hope someone can make use of it!

Bulk convert Safari's Web Archives to PDFs

I've been archiving web pages using Safari's one-file web archive format for a while. I was trying to figure out a bulk conversion method if I want to send these archives to Windows users, or switch to a different browser. It turns out that Scott Garner's Download URL as PDF Automator action can take web archive files from the Finder and will convert them to PDFs (in addition to its intended function of downloading pages off the web.)

Just download the Automator action, then create a workflow with Find Finder Items hunting through your home directory for files that have the extension webarchive. That action should feed into Scott's action, and you're all set. The action has some options, including whether or not the PDF should be split into pages.