void (Element rootElement) { rootElement.setAttribute(HOST, StringUtil.notNullize(getHost())); rootElement.setAttribute(PORT, StringUtil.notNullize(getLiteralPort())); rootElement.setAttribute(USERNAME, getSerializedUserName()); rootElement.setAttribute(PRIVATE_KEY_FILE, StringUtil.notNullize(getPrivateKeyFile())); rootElement.setAttribute(USE_KEY_PAIR, Boolean.toString(myAuthType == AuthType.KEY_PAIR)); rootElement.setAttribute(USE_OPENSSH_CONFIG, Boolean.toString(isOpenSshConfigUsageForced())); // the old `USE_AUTH_AGENT` attribute is used to avoid settings migration rootElement.setAttribute(USE_AUTH_AGENT, Boolean.toString(myAuthType == AuthType.OPEN_SSH)); boolean memoryOnly = (myAuthType == AuthType.KEY_PAIR && !isStorePassphrase()) || (myAuthType == AuthType.PASSWORD && !isStorePassword()) || myAuthType == AuthType.OPEN_SSH; String password; if (myAuthType == AuthType.KEY_PAIR) { password = getPassphrase(); } else if (myAuthType == AuthType.PASSWORD) { password = getPassword(); } else { password = null; } PasswordSafe.getInstance().set(createAttributes(memoryOnly), new Credentials(getUserName(), password)); // getConnectionConfigPatch() is omitted intentionally. // It's expected that the options will be set with SSH settings by one of `copyTo` calls. }