/// <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;
if(!_byIdentityFile.TryGetValue(identityKey, out jsch))
{
jsch = new JSch();
jsch.setHostKeyRepository(def.getHostKeyRepository());
jsch.addIdentity(identityKey);
_byIdentityFile.Add(identityKey, jsch);
}
return jsch;
}