Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Extension/RemoteDebuggerLauncher/PackageConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,18 @@ public static class SecureShell
public const string DefaultKnownHostsFileName = "known_hosts";

/// <summary>SSH key scanner arguments.</summary>
public const string KeyScanArguments = "-4 -p {1} {0}";
/// <remarks>No space after {2} because SshForceIPv4 includes a trailing space.</remarks>
public const string KeyScanArguments = "{2}-p {1} {0}";

/// <summary>Argument for SSH to force IPv4 usage.</summary>
public const string SshForceIPv4 = "-4 ";

/// <summary>SSH executable.</summary>
public const string SshExecutable = "ssh.exe";

/// <summary>The SSH arguments to add server fingerprint to known_hosts file.</summary>
public const string SshArguments = "{0}@{1} -p {2} -i \"{3}\" \"echo DONE\"";
/// <remarks>No space after {4} because SshForceIPv4 includes a trailing space.</remarks>
public const string SshArguments = "{0}@{1} {4}-p {2} -i \"{3}\" \"echo DONE\"";

/// <summary>HTTPS Developer Certificate name.</summary>
public const string HttpsCertificateName = "DevCert.pfx";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Threading;
using RemoteDebuggerLauncher.Infrastructure;
using Renci.SshNet;
Expand Down Expand Up @@ -106,7 +107,7 @@ public async Task AuthorizeKeyAsync(SecureShellKeySetupSettings settings)
var defaultKeysFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), PackageConstants.SecureShell.DefaultKeyPairFolder);
var knownHostsFilePath = Path.Combine(defaultKeysFolder, PackageConstants.SecureShell.DefaultKnownHostsFileName);

var arguments = string.Format(PackageConstants.SecureShell.KeyScanArguments, settings.HostName, settings.HostPort);
var arguments = string.Format(PackageConstants.SecureShell.KeyScanArguments, settings.HostName, settings.HostPort, settings.ForceIPv4 ? PackageConstants.SecureShell.SshForceIPv4 : string.Empty);
var startInfo = new ProcessStartInfo(PackageConstants.SecureShell.KeyScanExecutable, arguments)
{
CreateNoWindow = true,
Expand All @@ -124,6 +125,8 @@ public async Task AuthorizeKeyAsync(SecureShellKeySetupSettings settings)
var stdError = await process.StandardError.ReadToEndAsync();
var exitCode = await process.WaitForExitAsync();

await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

if (exitCode == 0)
{
if (FileHelper.ContainsText(knownHostsFilePath, settings.HostName))
Expand Down Expand Up @@ -155,7 +158,7 @@ private async Task<bool> RegisterServerFingerprintWithConnectionAsync(SecureShel
const string SshDoneMarker = "DONE";

// open a pseudo console windows to run the ssh command
var arguments = string.Format(PackageConstants.SecureShell.SshArguments, settings.UserName, settings.HostName, settings.HostPort, settings.PrivateKeyFile);
var arguments = string.Format(PackageConstants.SecureShell.SshArguments, settings.UserName, settings.HostName, settings.HostPort, settings.PrivateKeyFile, settings.ForceIPv4 ? PackageConstants.SecureShell.SshForceIPv4 : string.Empty);
var startInfo = new ProcessStartInfo(PackageConstants.SecureShell.SshExecutable, arguments)
{
CreateNoWindow = false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// <copyright company="Michael Koster">
// Copyright (c) Michael Koster. All rights reserved.
// Licensed under the MIT License.
Expand All @@ -17,6 +17,7 @@ namespace RemoteDebuggerLauncher.RemoteOperations
internal class SecureShellKeySetupSettings
{
private readonly bool forceIPv4;

public SecureShellKeySetupSettings(SetupSshViewModel viewModel)
{
HostName = viewModel.HostName;
Expand Down Expand Up @@ -67,5 +68,10 @@ public SecureShellKeySetupSettings(SetupSshViewModel viewModel)
/// Gets the private key file.
/// </summary>
public string PrivateKeyFile { get; }

/// <summary>
/// Gets a value indicating whether to force IPv4 usage.
/// </summary>
public bool ForceIPv4 => forceIPv4;
}
}

This file was deleted.

Loading