Currently this will not connect if the server forces a particular key type such as ed25519 which can prevent the script from connecting. This allows the server to connect if it detects a particular key in use by the user.
Not included in this change is a DSA key since they are typically being depreciated and therefore not recommended.