SSH Remote Desktop Selection

Apple Remote Desktop is an invaluable tool in the Mac sysadmin world providing functionality above and beyond the likes of VNC. There are however, a few things that we can’t do. For a lot of really geeky work we need an interactive shell via SSH. The problem is ARD only provides a simple Send UNIX command utility that pales in comparison to a fully functional SSH connection.

I made an applescript for a colleague of mine who wanted to be able to SSH a selection of machines in ARD. It’s not too smart as it doesn’t pull usernames or passwords from anywhere but it does speed up opening a connection to a target machine.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
tell application "Remote Desktop"
  set the_result to display dialog ¬
    "Username: " default answer ¬
    "systsupp" with icon 1 ¬
    buttons {"Cancel", "Connect"} ¬
    default button "Connect"
 
  set button_pressed to button returned of the_result
  set text_typed to text returned of the_result
 
  if (count of text_typed) > 0 then
    set ssh_command to "ssh " & text_typed & "@"
  else
    set ssh_command to "ssh "
  end if
 
  if button_pressed is "Connect" then
    set sel to selection
    repeat with i from 1 to length of sel
      set this_ip to Internet address of item i of sel
      tell application "Terminal"
        activate
        do script ssh_command & this_ip
      end tell
    end repeat
  end if
end tell

If you really want to speed things up you can set up a private/public OpenSSH key to enable password-less connections to your target machines. Of course, if you have multiple usernames this script becomes a little bit less useful!

I’ve written a quick how-to on setting up private/public OpenSSH keys to enable passwordless SSH connections at Open SSH keys.

Leave a Reply