Tuesday, 29 December 2015

Running sshd on El Capitan and compatibility with older versions

To allow myself a login on my home Mac, I open a port on my firewall and allow ssh traffic in.  I use 'prompt' on the iPad and iPhone for ssh access as well as using ssh to start VNC when using 'teleport' to allow sharing go my screen.

This all seemed to break under El Capitain as ssh access via the port over the WAN connection no longer seemed to work.

After some investigation it seems to be the case of the ciphers used by ssh on El Capitan not being as compatible as they could have been with the ssh version on the iPad.

So I did the following:

sudo vi /etc/ssh/sshd_config
And added the following line to the end of the file as one line:

Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,blowfish-cbc,aes128-cbc,3des-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc
I then could restart ssh on my new port and access it via the iPad/iPhone applications again.

According to the site itefix.net, this it may be related to the potentially incompatible changes introduced in OpenSSH 6.7 to remove unsafe algorithms.

Friday, 4 December 2015

Screen Sharing on El Capitan

Screen sharing on the Mac is really useful.  There are a few ways to do this once screen sharing is turned on in the System preferences pane.


  • You can select the machine name at the side of the Finder and then the "share screen" tab.
  • You can run the 'Screen Sharing' App from Spotlight or directly from "/System/Library/CoreServices/Applications/Screen Sharing"

However, did you know that when you connect via screensharing to different remote, a file is created in your home directory at 
~/Library/Containers/com.apple.ScreenSharing/Data/Library/Application Support/Screen Sharing/
containing information on how you connected to the machine?  The good thing about these files is that they can be used to reconnect to the machines by just double clicking on them.  This means that you can use screen sharing to connect to a machine much faster than the two methods shown above.

To make this more convenient for me to use I did the following.

  • Created a folder in my home directory called "Remote Machines"
  • In the Finder, select "Go" and then press the "ALT/Option" key to show the hidden folder 'Library" and then navigate down to ~/Library/Containers/com.apple.ScreenSharing/Data/Library/Application Support/Screen Sharing/
  • Option/ALT click and drag all of the files to the "Remote Machines" folder created above to copy them, rather than move them.
  • Drag the "Remote Machines" folder into the right-hand side of the dock (to the right of the faint-white lines which separate the Trash from applications)

Now when you click on that folder in the dock, you'll see a list of machines that you can connect to directly.  You can add to this folder at any time when you connect to new machines.

Note that this is not limited to other OSX machines, the files are also created if you connect with a standard VNC protocol to another machine running VNC.  e.g. Linux VNC server, Raspberry Pi VNC server etc.

Now that the folder has the links to start off a screen sharing session, the icons can be changed to make them more meaningful.  Follow my post on this for details on how to do this in El Capitan.

The same method can be used under previous versions of OSX, but the location of the Screen Saring folder is different.  e.g. under Lion they are held under:

~/Library/Application Support/Screen Sharing/

Other locations in other releases are left as an exercise for the reader.



Monday, 19 October 2015

Icon Changing in El Capitan

I have a couple of automator actions that I use to wrap up a command line.  Specifically I use:

'...<path to binary>Firefox.app/Contents/MacOS/firefox-bin' -P JR02 -no-remote >/dev/null 2>&1 &

as a shell script to fire up firefox automatically using another profile. 

When I copied this action across to El Capitan, the icon didn't migrate.  This is what I needed to do to change the icon back to a copy of the firefox icon.


  1. Find the original Firefox application and then right click and 'Get Info'
  2. At the top left of the Info window is the icon.  Click on this (it will then have a blue border around it) and press CMD-C to copy the icon.  You can't right click.
  3. Right click on the new copy and 'Get Info'.  Click on the same place on the window, but  press CMD-V to paste the new icon in.




  4. Now close the Get info windows.  You'll notice that the icon hasn't changed.  At this point it would have under Yosemite, so you need to fool the system.  You do this by just copying the icon and the new copy has the new icon in it.  I do this by pressing Alt/Option, clicking on the icon of the app and dragging it.  You'll see the green "+" showing a copy is being made and when you release, the copy will have the updated icon.  Now, just delete the original and rename the copy.


Monday, 5 October 2015

Dtrace broken under El Capitan

One of the tools that I use quite a lot in debugging in 'dtrace' and the various utilities that use it.  e.g. open snoop, iotop and a few that I wrote myself.

With the GA of El Capitan, any utility that resides in a system directory cannot be traced by dtrace, which is a bit of a problem.  I was wanting to see what open system calls the Photos app was using and came across this.


I know I could have used some other Mac utilities (fs_usage, sc_usage etc.) but I'm showing my Solaris roots here and still wanted to use dtrace.


Fortunately there looks to be a way of enabling dtrace:

  1. Reboot the mac
  2. Hold ⌘R during reboot
  3. From the Utilities menu, run Terminal
  4. Enter the following command
csrutil enable --without dtrace

Note, that when doing so I got the following warning:
This is an unsupported configuration, likely to break in the future and leave your machine in an unknown state.
I'll live with it just now.
Also changed the boot delay on the VMware machine by bios.bootdelay = 20000 in the vmx file.

Photos Migration to El Capitan

Well, that was easy.

Just drag the 'Photos Library,photo library' file from the old Mac to the new one and start Photos on the new Mac.  Wait for the import and ensure that the preferences are set the way that you want and it works.

I could have downloaded the library from iCloud, but that wouldn't have imported the Faces (as far as I know) and also taken much longer.

Also, seeing "Updated Just Now · Unable to Upload 96 Items"  - don't know what that's all about, but I'll look into it.

Updated 7th Oct
It looks like the issue was the way that I coped the photo library over.  I used the VMware Shared folders on the Virtual Mac to connect to the Pictures folder and copy the library across.  I then closed Photos, Moved the current library to the trash and then emptied the trash.  Then I connected via AFP to the directory on my real mac and copied the library over.  At this point, the "Unable to Upload 96 Items" has gone and the libraries are in sync.



Sunday, 4 October 2015

iBooks migration to a new OS

As per my previous post, I'm in the process of a very methodical upgrade to El Capitan via a new install and manual migration on a VM.  One of my issues was that I want to keep various installed programs with their respective data complete.  e.g. Mail, iBooks, iTunes etc. iBooks looked like it was going to be a problem, as I want to keep my collections and metadata on the new OS.

After quite a few failed attempts, I have a process that worked for me.



  1. On my destination Mac in the VM
    • Hold down the option key and select Go >> Library from the Finder menu.  Move the following items, if they exist, to the Trash
    Cookies/com.apple.ibooks.cookies
    Preferences/com.apple.ibooks.plist
    Containers/com.apple.iBooksX
    • Move the following item to the desktop.  Don’t move it to the Trash
     Containers/com.apple.BKAgentService


  2. Then, restart the Mac.

  3. Don’t open iBooks.

    After restarting, copy the folders that were deleted/moved in the previous step from the source Mac to the destination Mac.  I mounted my home directory as a shared folder in the VM and then copied the files across with the finder.  This seemed the easiest for me and it did work.

    Don’t open iBooks yet.



  4. Now restart the VM Mac.
After this final restart, iBooks can be opened, and it should be the same as the original Mac, down to the window size and position.

There may be steps where you can skip the reboot of the Mac and/or moving of files, but this method is the one that finally worked for me.

Migration to El Capitan

This time around, I wanted to install a new OS from Apple as a pristine version and install/migrate my apps across as needed.  My current idea is to do this using the following method:
  1. Create a virtual machine under Fusion 8 with 800G of disk space and install El Capitan on it as a new OS release.
  2. Personalise it as if it were a new machine with iCloud accounts etc.
  3. Migrate any new software across via installs and not using the migration assistant.
  4. When happy, attach an external disk and create a time machine backup.
  5. Install El Capitain on by main partition, and the use migration assistant to migrate from my virtualised machine.
Of course, I will be having extra backups around of my original machine, in case things go worng (sic) backed up via Carbon Copy Cloner and Time machine, so if it all goes pear-shaped, I'll be able to revert to a working Yosemite build and then try again.

I'll be posting any issues that I have as I encounter them with, hopefully, the resolutions.

Friday, 4 September 2015

DVD-Less Install of Leopard on PPC

I have an old PPC G5 Mac (2004) which I wanted to clean up and re-install Leopard (OSX 10.5.8) on it so that it would be as good as new.  The only problem that I had was that the Leopard Install disk, for some reason, the iMac wont read. I did have an external DVD drive so I could read the disk on the machine though.

Since this is a PowerPC Mac, the option of booting off the external USB DVD ROM is not possible, so here are the steps I used to install a new version of OSX 10.6 on the iMac.

Overview:

  1. Create a new partition on the boot disk
  2. create the DVD image
  3. copy the DVD image onto the new parition
  4. select that as the start disk
  5. restart the iMac and install onto the other partition.

  • The new partition on the boot disk needs to be performed in 2 steps.  Whenever I tried to split the existing partition and create a new one, it always failed.  Open Disk utility and select the main disk on the Left Hand menu.  This is the "parent" of the hard disk.  In my case it is "149.1GB WDC..."


  • Click 'Partition' and then Change the current selection from 1 to 2.  Then select the new partition and change the size to 10GB and it's name to something better;  I chose 'Image".  Select Apply and wait for the change to occur.



  • Now it's time to create the disk image of the Leopard install disk.  In this case I'm using an external drive and insert the Leopard disk into that.  If you already have a DMB file of the install disk, you can skip these steps obviously. 
  • Start up Disk utility with the DVD installed

  • Go to the menu on the left and highlight the name of the disk you mounted.
  • Click on the File menu at the top of the screen. From the drop-down menu, click New, then Disk Image From [name of your disk].

  • Save the image on the desktop and select the type as 'read only'

  • When finished, the DMG file will be on the desktop and also appear in the left hand pane.

  • Now click on the 'Restore' Tab of Disk Utility
  • Drag the Image file from the desktop onto the 'Source' Box.
  • Drag the 'Image' Partition created earlier onto the Destination Box.

  • Click on 'Restore' to copy the image onto the partition.  Click through the dialog boxes and enter your password when prompted.  At this point an error dialog may appear about not being able to usethe image.  If this occurs, select 'Images' -> 'Scan Image for Restore' and select the DMG file on the desktop.  Then repeat the step and it should work.
  • Once the process is complete, exit Disk Utility and open System Preferences and go to 'Startup Disk'.  Select the disk image just created, then click restart.  Click through the dialog boxes, and your mac will shutdown and boot up the Leopard Install disk.  Follow through the normal install process and a pristine version of Leopard will be installed.

Friday, 7 August 2015

Physical Yosemite Machine to VMware fusion Image

Physical to Virtual under VMware fusion

With El Capitan just around the corner I like to keep a copy of my currently running machine around just in case.  I previously used a tortuous method of keeping my old Mountain Lion image around while migrating to Yosemite, which took about 3 attempts and over a week to get working.  This time round, I've got a much easier method which uses no intermediate disk space making the process quicker as there is less copying of data around.

What you need:
  • The Yosemite Install Image from the Mac store.
  • A current version of VMware Fusion (I'm using version 7.1.2)
  • Carbon Copy Cloner (I'm using version 4.1.3). Other disk cloning utility may work, but this is the one I use regularly for my backups and it works for me and the specifics in this tutorial will use CCC.
  • A passing experience of using the terminal command line.
  • Optional - A copy of 'Beamoff' to optimise the screen when running Yosemite in a VM.  This utility, along with a discussion on why it is needed under Fusion 7, can be found at this insanely mac forum post.  VMware have promised this will be in a future version of the vmware tools but, as of writing this, it is not included.

Method

  1. Create a new VMware fusion image.  Use the 'Disc Image' open, and select Continue
  2. Now, use the finder to find the 'Install OS X Yosemite' application.  It should be under /Applications.  If it is not, then you may have to open the App store, go to 'Purchased Items' and download it again.  Select this image and drag it onto the middle of the window.  If you have problems, or it does not work, use the 'Select another disc image' button and navigate to the Yosemite Image and select it.
  3. Select the Yosemite image and press 'Continue'
  4. Click 'Customize Settings'.  A new widow will pop up asking where the image is to be saved, and what name so complete this and continue.  It will then create an installation image for a few minutes:
  5. Change whatever else is normally changed for your VM machine here.  I like to remove the sharing of bluetooth devices or else my mouse and trackpad can often change their focus to be the VM and not my main mac which can be annoying.

    However, the important step that needs to be followed is the creating of a new virtual disk which is the at least the same size as the physical disk from which you want to clone.  You will notice that there are 2 disks initially; the reason for this is that 'Hard disk 2' is the temporary installation disk.
  6. Select the 'Add Device' along the top, Select 'New Hard Disk' and the click 'Add' at the bottom of the tab. Select the correct size and click 'Apply'.  I've chose an image of 1TB for my example below.  Note that after you click 'Apply' all that will happen in the all the buttons grey out showing the task has been completed.  Select 'Show All' to go back to the full setting list.
  7. Now, we're ready to install, so go ahead and start the VM and install Yosemite as normal.
  8. Skip all of the Apple ID stuff and just create a basic machine when the startup process asks for it.  At the end of it all, the machine will boot, but you will get an error on the screen "The disk you inserted was not readable by this computer".  This is the 2nd disk that was added in the stage above.  Go ahead and select 'Initialize' which will start 'Disk Utility'.
  9. Select the large disk image from the left hand tab:

  10. and then change the Partition Layout to '1 Partition' and ensure the Format is 'Mac OS Extended (Journaled)';  it must not be 'case sensitive'. Also, change the name to something reasonable:

  11. Click 'Apply' and then the next popup and the new disk will be formatted.  You may get a new pop-up asking if you want to use the disk as a time machine backup.  You don't.
  12. Now quit disk utility and you should see the new disk appear on the desktop.  At this point, click the 'Virtual Machine' menu from Fusion and select 'Install VMware tools' and then follow the prompts to install the tools, rebooting at the end as required.


  13. For the transfer of the image, you will need the network address of this machine, so open 'System Preferences' and select 'Network'.  You should see a window line the one below with the active IP address of the machine.  Make a note of this address.

  14. At the same time as this, you need to enable the remote login services under the 'sharing' preferences pane.  Do this now, or else Carbon Copy Cloner will complain when you install it.
  15. On your physical machine, start up Carbon Copy Cloner and create a new task.  As your source disk, select the physical disk you want to clone - normal 'Macintosh HD' and select 'All files' to clone
  16. Under Destination, under 'Other Destinations', select 'Remote Macintosh' and then put the IP address recorded above, and put the 'Path to destination folder' as /Volumes/<name of the 2nd disk>.  e.g:


  17. Before continuing, click the 'Create Authentication Credentials package' button and follow the steps to create a package locally. Ideally, save this package on your desktop.  After it has created the package, click 'OK'.
  18. Now, select the package just created on the desktop and drag it over your running VM.  When you get over the virtual screen and release it, it should copy to the remote VM desktop.
  19. Before continuing, the CCC package just copied across needs to be changed slightly to work.  CCC uses the same package on both source and destination machines to install the keys required to work but uses the hardware address to work out if the package is being run on a machine where there package was created.  For a virtual machine, the HW addresses are the same so the installation script on the Virtual machine needs to be changed slightly so that the 'sourceHW' variable is different.
  20. Assuming the package is on the desktop, the following command line will change the contents of the package to work correctly and assume that this is a client machine for the purposes of Carbon Copy Cloner.  Open the terminal and type the following command (all on one line - it may be split up when viewing here).   I've used shell wild cards a lot here to reduce the amount needed to type and to fit on one line.
  21. perl -pi -e 's/^s.*W=.*/sourceHW="deadbeef"/' ~/D*/Au*.pkg/C*/R*/p*t

  22. (For those wishing to be more circumspect about changing this, what needs to occur is a change to the variable 'sourceHW' in the 'post flight' script contained within the package.  It must be set to a different value to allow the package to install correctly.)  The expanded path that needs to be edited is $HOME/Desktop/Authentication Credentials from*.pkg/Contents/Resources/postflight" where the name of the package will vary depending on the name of the machine on which it was created.
  23. Double click the package on the desktop of the VM to install it, and follow the prompts.
  24. The package the CCC created on your physical machine now needs to be run as well. Double click on the package created on your physical machine's desktop and follow the prompts.
  25. At this point, everything is set up for the copying of the Physical to the virtual machine.  On CCC click the 'Clone' button and watch to see the data being transferred across.
  26. When the transfer has completed, shut down the virtual machine
  27. Click on the settings for the virtual machines and select the new virtual hard disk as the new boot drive in the setting section under "Startup Disk" and then click restart.  The machine should now but up as a copy of the physical machine.

Post Install Tasks

Now that this is complete, you'll notice on reboot a few things not quite working 100%.  These are easy to fix.
  1. The VM machine will have the same as the physical machine.  There will be a warning message popping up about two machines on the same network with the same name, but Yosemite will rename the VM to stop the conflict.  If you want to change it to something better, go to 'System Preferences' -> 'Sharing' and change the 'Computer Name' to something you want.
  2. The install of VMware tools will have been overwritten.  The tools will need to be re-installed so that the screen can be resized, drag and drop work etc.
That should be it all.  Hopefully this will help others who have wanted to virtualize their macs.

Updating The Image

If you need to update the image with a later copy you should not use Carbon Copy Cloner to copy disk onto of the current running image.  You need to do the following to the virtual Mac:

  1. Shut down the virtual Mac.
  2. In VMware tools, change the boot disk to be the initial disk you creating the initial OS image on.  i.e. change it from the current disk to the other one. 
  3. Save and restart.  When the VM boots, the original OS image will be booted and you can carry on to clone the physical machine as in steps 22 and above.