code: protected File[] findSshPrivateKeys(File[] sshDirs) {
          ArrayList<File> files = new ArrayList<File>();
  
          // search every directory
          for (File sshDir : sshDirs) {
              File f0 = new File(sshDir, "id_dsa");
              if (f0.exists() && f0.canRead() && f0.isFile()) {
                  files.add(f0);
              }
  
              File f1 = new File(sshDir, "id_rsa");
              if (f1.exists() && f1.canRead() && f1.isFile()) {
                  files.add(f1);
              }
          }
  
          return files.toArray(new File[0]);
      }
docs: Best attempt to find all .ssh private keys (identity) by searching inside
  every provided .ssh directory.  Currently searches for any "id_rsa" or
  "id_dsa" files.