I have been using the simple hostname to ssh into remote hosts, around 100 systems. There has been a change in configuration of the network that will require FQDNs.

Rather than recreating all my remote system names (stored in terminal and shown when pressing shift-command-k )

Can I edit the stored data to add the domain information to the existing entries?

  • 1
    I think you need to run one more time as when you add FQDN , it will create a new RSA key fingerprint. – Udhy Feb 12 '20 at 16:59
  • 1
    @Udhy - that's not the question being asked. The saved host names are found when you hit Shift-Cmd-K. It's like an address book of hosts and has nothing to do with the fingerprint. – Allan Feb 12 '20 at 18:58
  • The editors did not like me adding the correct solution directly into the question. While the solution I found that worked is based on a reply to this question it is subtly different which is not obvious unless you are actually trying to do the work. – Darryl Baker Feb 18 '20 at 16:43
  • Solution What I did was to get the hosts using "defaults read -app Terminal PermanentServers > foo.sh" Then I erased the current data "defaults delete -app Terminal PermanentServers" I edited foo.sh to have lines like: defaults write -app Terminal PermanentServers -array-add "systema.example.com" defaults write -app Terminal PermanentServers -array-add "systemb.example.com" Finally I ran foo.sh, restarted terminal and selected "new remote command" from the Shell dropdown and there were all the systems as FQDNs – Darryl Baker Feb 18 '20 at 16:44

The host names are stored in the Terminal settings .plist in the users /Library/Preferences folder:


Edit the .plist

The easiest way to edit a batch of these is by editing the plist with a tool like VSCode (free) with the Binary Plist Extension or your favorite text editor with plist support.1 You can also convert the plist to XML (and back to binary) using plutil.2 This will allow you to use any text editor like TextEdit that doesn't natively support plist formats.

Important: I suggest making a backup copy of the plist before you start editing in case you want to revert back to the original.

You can find all of your servers in the array under the PermanentServers key as shown below. Simply go in and fix the FDQN as needed. If the domain suffixes are all the same, a simple Find/Replace should speed through the task.

com.apple.Terminal.plist PermanentServer key

Save the file and reload Terminal. For this example, I added the FQDN .newFQDN to each entry and restarted Terminal. Here's the result:

New Remote Connection Updated Results

Alternate Method using defaults read/write

You can get the names of the server with the defaults read command:

$ defaults read -app Terminal PermanentServers


You can set your new servers by overwriting that array with a new one as follows:

$ defaults write -app Terminal PermanentServers -array '(host1.newFQDN, host2.newFQDN, host3.newFQDN, host4.newFQDN)'

You can then reissue the defaults read command to check the results. The upside to this is that you don't need TextWrangler and you can script it. However, it's difficult to do a large number on the command line so, you'll want to edit it first in a text editor to make sure you have no mistakes.

1 In the first version of this answer, I originally referred to TextWrangler as it was a tool I originally used to view/edit plist files. However, I've been transitioning to VSCode as it's cross platform - macOS, Windows, and even FreeBSD, I discovered a plist plugin that allowed me to finally get rid of TextWrangler, not that it's "bad" in any way; I'm just trying to streamline my dev tools.

2 To convert a binary plist to XML for editing, issue the command plutil -convert xml1 foobar.plist. Once you're finished editing, save it then convert it back to binary with the command plutil -convert binary1 foobar.plist

  • FYI - TextWrangler is no longer supported, and 32-bit so it won't work on Catalina, but you can use the free version of BBEdit to open .plist files without having to convert them to text first. It's by the same company that made TextWrangler and does more than TextWrangler used to do. – TJ Luoma Feb 13 '20 at 1:24
  • @TJLuoma - good to know. I haven't gone to Catalina yet because of this 32bit issue. I've gone over the VS Code and I think I'm sticking with it. – Allan Feb 13 '20 at 1:32

If all you're worried about is being able to ssh in, you might not need to change how you connect at all.

You can make aliases in ~/.ssh/config which refer to other hosts. For example, if you want to be able to do ssh shortie instead of ssh somehostname.plus.fqdn you would use this in ~/.ssh/config:

Host shortie
    HostName somehostname.plus.fqdn
    HostKeyAlias somehostname.plus.fqdn

The HostKeyAlias tells ssh which hostname to use in ~/.ssh/known_hosts for verifying this connection, so you might want to use the FQDN for that.

I would try that with one of your hosts and see if it works for you. If it does, editing ~/.ssh/config is certainly the easiest fix, and you can copy it to other computers if you want/need.

You can also assign multiple aliases, too.

The nice thing about doing this as the ssh level is that it will work for Terminal.app, iTerm, and any other tools that use ssh.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .