diff --git a/salt/client/ssh/__init__.py b/salt/client/ssh/__init__.py
index <HASH>..<HASH> 100644
--- a/salt/client/ssh/__init__.py
+++ b/salt/client/ssh/__init__.py
@@ -372,7 +372,11 @@ class SSH:
                 roster_data = self.__parsed_rosters[roster_filename]
                 if not isinstance(roster_data, bool):
                     for host_id in roster_data:
-                        if hostname in [host_id, roster_data[host_id].get("host")]:
+                        if isinstance(roster_data[host_id], salt.utils.odict.OrderedDict):
+                            roster_host = roster_data[host_id].get("host")
+                        else:
+                            roster_host = roster_data[host_id]
+                        if hostname in [host_id, roster_host]:
                             if hostname != self.opts["tgt"]:
                                 self.opts["tgt"] = hostname
                             self.__parsed_rosters[self.ROSTER_UPDATE_FLAG] = False
Fix #<I>: salt-ssh error when targetting IPs or hostnames directly