/// <summary> /// Obtain the JSch used to create new sessions. /// </summary> /// <param name="hc">host configuration</param> /// <returns>the JSch instance to use.</returns> protected JSch getJSch(OpenSshConfig.Host hc) { if (hc == null) { throw new System.ArgumentNullException("hc"); } JSch def = getDefaultJSch(); FileInfo identityFile = hc.getIdentityFile(); if (identityFile == null) { return(def); } string identityKey = identityFile.FullName; JSch jsch = _byIdentityFile[identityKey]; if (jsch == null) { jsch = new JSch(); jsch.setHostKeyRepository(def.getHostKeyRepository()); jsch.addIdentity(identityKey); _byIdentityFile.Add(identityKey, jsch); } return(jsch); }
protected JSch getJSch(OpenSshConfig.Host hc) { JSch def = getDefaultJSch(); FileInfo identityFile = hc.getIdentityFile(); if (identityFile == null) { return(def); } string identityKey = Path.GetFullPath(identityFile.ToString()); JSch jsch = byIdentityFile[identityKey]; if (jsch == null) { jsch = new JSch(); jsch.setHostKeyRepository(def.getHostKeyRepository()); jsch.addIdentity(identityKey); byIdentityFile.Add(identityKey, jsch); } return(jsch); }