From ff68f6757abf806d6e04231fd4e824b47aa692d5 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Wed, 6 Mar 2024 12:39:19 -0500 Subject: [PATCH 1/5] Bump version. Added SSH connection logging --- src/VsLinuxDebugger/Core/SshTool.cs | 3 +++ src/VsLinuxDebugger/Properties/AssemblyInfo.cs | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/VsLinuxDebugger/Core/SshTool.cs b/src/VsLinuxDebugger/Core/SshTool.cs index 4b52d88..d911f59 100644 --- a/src/VsLinuxDebugger/Core/SshTool.cs +++ b/src/VsLinuxDebugger/Core/SshTool.cs @@ -162,6 +162,8 @@ public async Task ConnectAsync() { if (_info.PrivateKeyEnabled) { + Logger.Output($"SSH configuring private key connection..."); + if (string.IsNullOrEmpty(_info.PrivateKeyPassword)) keyFile = new PrivateKeyFile(_info.PrivateKeyPath); else @@ -184,6 +186,7 @@ public async Task ConnectAsync() try { + Logger.Output($"SSH connecting..."); if (_info.PrivateKeyEnabled && File.Exists(_info.PrivateKeyPath)) _ssh = new SshClient(conn); else diff --git a/src/VsLinuxDebugger/Properties/AssemblyInfo.cs b/src/VsLinuxDebugger/Properties/AssemblyInfo.cs index 132fadc..8c716ac 100644 --- a/src/VsLinuxDebugger/Properties/AssemblyInfo.cs +++ b/src/VsLinuxDebugger/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -10,7 +9,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Xeno Innovations, Inc.")] [assembly: AssemblyProduct("VS Linux Debugger")] -[assembly: AssemblyCopyright("Copyright 2022-2023 Xeno Innovations, Inc.")] +[assembly: AssemblyCopyright("Copyright 2022-2024 Xeno Innovations, Inc.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -29,5 +28,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.1.3")] -[assembly: AssemblyFileVersion("2.1.1.3")] +[assembly: AssemblyVersion("2.1.2.3")] +[assembly: AssemblyFileVersion("2.1.2.3")] From df48720f2d08abcbcc338e874e98f566d9b7a28a Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 7 Mar 2024 16:03:39 -0500 Subject: [PATCH 2/5] Reverted RsaSha256 workaround as per SSH.NET v2023 upgrade (https://github.com/sshnet/SSH.NET/issues/825#issuecomment-1984366346) --- .../Security/RsaSha256DigitalSignature.cs | 2 ++ .../Core/Security/RsaSha256Util.cs | 7 +++- .../Security/RsaWithSha256SignatureKey.cs | 2 ++ src/VsLinuxDebugger/Core/SshTool.cs | 32 +++++++++---------- src/VsLinuxDebugger/VsLinuxDebugger.csproj | 2 +- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/VsLinuxDebugger/Core/Security/RsaSha256DigitalSignature.cs b/src/VsLinuxDebugger/Core/Security/RsaSha256DigitalSignature.cs index c0096ad..1911655 100644 --- a/src/VsLinuxDebugger/Core/Security/RsaSha256DigitalSignature.cs +++ b/src/VsLinuxDebugger/Core/Security/RsaSha256DigitalSignature.cs @@ -6,6 +6,7 @@ namespace VsLinuxDebugger.Core.Security { + /* /// /// Based on https://github.com/sshnet/SSH.NET/blob/1d5d58e17c68a2f319c51e7f938ce6e964498bcc/src/Renci.SshNet/Security/Cryptography/RsaDigitalSignature.cs#L12 /// @@ -62,4 +63,5 @@ protected override byte[] Hash(byte[] input) return _hash.ComputeHash(input); } } + */ } diff --git a/src/VsLinuxDebugger/Core/Security/RsaSha256Util.cs b/src/VsLinuxDebugger/Core/Security/RsaSha256Util.cs index 435f3d4..d47672f 100644 --- a/src/VsLinuxDebugger/Core/Security/RsaSha256Util.cs +++ b/src/VsLinuxDebugger/Core/Security/RsaSha256Util.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Reflection; using System.Security.Cryptography; using Renci.SshNet; @@ -14,6 +15,7 @@ namespace VsLinuxDebugger.Core.Security /// public static class RsaSha256Util { + /* /// RSA SHA2 256. public const string RSA_SHA2_256 = "rsa-sha2-256"; @@ -26,12 +28,14 @@ public static class RsaSha256Util /// Argument Null Exception. public static void ConvertToKeyWithSha256Signature(PrivateKeyFile keyFile) { - var oldKeyHostAlgorithm = keyFile.HostKey as KeyHostAlgorithm; + //// var oldKeyHostAlgorithm = keyFile.HostKey as KeyHostAlgorithm; + var oldKeyHostAlgorithm = keyFile.HostKeyAlgorithms.First(); if (oldKeyHostAlgorithm == null) { throw new ArgumentNullException(nameof(oldKeyHostAlgorithm)); } + //// var x = new KeyHostAlgorithm("name", key: null, digitalSignature: new RsaDigitalSignature(null)); var oldRsaKey = oldKeyHostAlgorithm.Key as RsaKey; if (oldRsaKey == null) { @@ -59,5 +63,6 @@ private static void UpdatePrivateKeyFile(PrivateKeyFile keyFile, RsaWithSha256Si var keyField = typeof(PrivateKeyFile).GetField("_key", BindingFlags.NonPublic | BindingFlags.Instance); keyField.SetValue(keyFile, key); } + */ } } diff --git a/src/VsLinuxDebugger/Core/Security/RsaWithSha256SignatureKey.cs b/src/VsLinuxDebugger/Core/Security/RsaWithSha256SignatureKey.cs index d94942f..6d2d444 100644 --- a/src/VsLinuxDebugger/Core/Security/RsaWithSha256SignatureKey.cs +++ b/src/VsLinuxDebugger/Core/Security/RsaWithSha256SignatureKey.cs @@ -4,6 +4,7 @@ namespace VsLinuxDebugger.Core.Security { + /* /// RSA With SHA256 Signature Key. public class RsaWithSha256SignatureKey : RsaKey { @@ -28,4 +29,5 @@ public override string ToString() return RsaSha256Util.RSA_SHA2_256; } } + */ } diff --git a/src/VsLinuxDebugger/Core/SshTool.cs b/src/VsLinuxDebugger/Core/SshTool.cs index d911f59..8e0badf 100644 --- a/src/VsLinuxDebugger/Core/SshTool.cs +++ b/src/VsLinuxDebugger/Core/SshTool.cs @@ -4,8 +4,10 @@ using System.IO; using System.Text.RegularExpressions; using System.Threading.Tasks; +using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; using Renci.SshNet; using Renci.SshNet.Common; +using Renci.SshNet.Security; using SharpCompress.Common; using SharpCompress.Writers; using VsLinuxDebugger.Core.Security; @@ -157,7 +159,7 @@ public async Task CleanFolderAsync(string path) public async Task ConnectAsync() { PrivateKeyFile keyFile = null; - ConnectionInfo conn = null; + ConnectionInfo connInfo = null; try { if (_info.PrivateKeyEnabled) @@ -169,12 +171,13 @@ public async Task ConnectAsync() else keyFile = new PrivateKeyFile(_info.PrivateKeyPath, _info.PrivateKeyPassword); + /** // adds rsa-sha2-256 RsaSha256Util.ConvertToKeyWithSha256Signature(keyFile); var authenticationMethodRsa = new PrivateKeyAuthenticationMethod(_info.UserName, keyFile); - conn = new ConnectionInfo(_info.Host, _info.Port, _info.UserName, authenticationMethodRsa); - RsaSha256Util.SetupConnection(conn); - + connInfo = new ConnectionInfo(_info.Host, _info.Port, _info.UserName, authenticationMethodRsa); + RsaSha256Util.SetupConnection(connInfo); + */ } } catch (Exception ex) @@ -187,10 +190,9 @@ public async Task ConnectAsync() try { Logger.Output($"SSH connecting..."); - if (_info.PrivateKeyEnabled && File.Exists(_info.PrivateKeyPath)) - _ssh = new SshClient(conn); - else - _ssh = new SshClient(_info.Host, _info.Port, _info.UserName, _info.UserPass); + _ssh = (_info.PrivateKeyEnabled && File.Exists(_info.PrivateKeyPath)) + ? new SshClient(_info.Host, _info.Port, _info.UserName, keyFile) + : new SshClient(_info.Host, _info.Port, _info.UserName, _info.UserPass); await Task.Run(() => _ssh.Connect()); } @@ -202,20 +204,18 @@ public async Task ConnectAsync() try { - if (_info.PrivateKeyEnabled && File.Exists(_info.PrivateKeyPath)) - _sftp = new SftpClient(conn); - else - _sftp = new SftpClient(_info.Host, _info.Port, _info.UserName, _info.UserPass); + _sftp = (_info.PrivateKeyEnabled && File.Exists(_info.PrivateKeyPath)) + ? new SftpClient(connInfo) + : new SftpClient(_info.Host, _info.Port, _info.UserName, _info.UserPass); _sftp.Connect(); } catch (Exception) { - if (_info.PrivateKeyEnabled && File.Exists(_info.PrivateKeyPath)) - _scp = new ScpClient(conn); - else - _scp = new ScpClient(_info.Host, _info.Port, _info.UserName, _info.UserPass); + _scp = (_info.PrivateKeyEnabled && File.Exists(_info.PrivateKeyPath)) + ? new ScpClient(connInfo) + : new ScpClient(_info.Host, _info.Port, _info.UserName, _info.UserPass); _scp.Connect(); } diff --git a/src/VsLinuxDebugger/VsLinuxDebugger.csproj b/src/VsLinuxDebugger/VsLinuxDebugger.csproj index 1308f72..05746ec 100644 --- a/src/VsLinuxDebugger/VsLinuxDebugger.csproj +++ b/src/VsLinuxDebugger/VsLinuxDebugger.csproj @@ -104,7 +104,7 @@ 0.30.1 - 2020.0.2 + 2023.0.1 6.0.2 From 8af0e4c754a36b9346c828b79eecd6a6600daae7 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 7 Mar 2024 16:11:49 -0500 Subject: [PATCH 3/5] Updated release notes. Bumpted to v2.2.0 --- readme.md | 3 +++ release-notes.md | 14 ++++++++++++++ src/VsLinuxDebugger/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index f058894..ab45aa3 100644 --- a/readme.md +++ b/readme.md @@ -108,3 +108,6 @@ To contribute, please pick off an item from the project or issue page. We'd love * [Extension Docs](https://docs.microsoft.com/en-us/visualstudio/extensibility/creating-a-settings-category?view=vs-2022) * [Extension Sample](https://github.com/microsoft/VSSDK-Extensibility-Samples/tree/master/Options) * [Offroad Debugging](https://github.com/Microsoft/MIEngine/wiki/Offroad-Debugging-of-.NET-Core-on-Linux---OSX-from-Visual-Studio) + + +_Copyright 2024 Xeno Innovations, Inc._ diff --git a/release-notes.md b/release-notes.md index f654dae..dca1dd5 100644 --- a/release-notes.md +++ b/release-notes.md @@ -4,6 +4,20 @@ This document contains the release information for the project. +### 2.2.0 + +* Fixed: Support VS v17.9 (#79) +* Update: SSH.NET to v2023.0.1 + +### 2.1.1 + +* Update: Version 2.1 and Code Housekeeping by @DamianSuess in #65 +* Update: GUI .NET 6 Sample NuGet packages by @DamianSuess in #68 +* Update: PR Template by @DamianSuess in #69 +* Update: Release build generator script by @DamianSuess in #70 +* Update: Quality control by @DamianSuess in #74 +* Update: Upgrade github actions by @DamianSuess in #75 + ### 2.1 * Update: Code cleanup diff --git a/src/VsLinuxDebugger/Properties/AssemblyInfo.cs b/src/VsLinuxDebugger/Properties/AssemblyInfo.cs index 8c716ac..0b7c19c 100644 --- a/src/VsLinuxDebugger/Properties/AssemblyInfo.cs +++ b/src/VsLinuxDebugger/Properties/AssemblyInfo.cs @@ -28,5 +28,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.2.3")] -[assembly: AssemblyFileVersion("2.1.2.3")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] From 4478b680083064d12d7a2195810063ddf5e47868 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Fri, 8 Mar 2024 09:11:01 -0500 Subject: [PATCH 4/5] Removed deprecated code fixtures --- .../Security/RsaSha256DigitalSignature.cs | 67 ------------------ .../Core/Security/RsaSha256Util.cs | 68 ------------------- .../Security/RsaWithSha256SignatureKey.cs | 33 --------- src/VsLinuxDebugger/Core/SshTool.cs | 6 +- src/VsLinuxDebugger/VsLinuxDebugger.csproj | 3 - 5 files changed, 1 insertion(+), 176 deletions(-) delete mode 100644 src/VsLinuxDebugger/Core/Security/RsaSha256DigitalSignature.cs delete mode 100644 src/VsLinuxDebugger/Core/Security/RsaSha256Util.cs delete mode 100644 src/VsLinuxDebugger/Core/Security/RsaWithSha256SignatureKey.cs diff --git a/src/VsLinuxDebugger/Core/Security/RsaSha256DigitalSignature.cs b/src/VsLinuxDebugger/Core/Security/RsaSha256DigitalSignature.cs deleted file mode 100644 index 1911655..0000000 --- a/src/VsLinuxDebugger/Core/Security/RsaSha256DigitalSignature.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Security.Cryptography; -using Renci.SshNet.Common; -using Renci.SshNet.Security.Cryptography; -using Renci.SshNet.Security.Cryptography.Ciphers; - -namespace VsLinuxDebugger.Core.Security -{ - /* - /// - /// Based on https://github.com/sshnet/SSH.NET/blob/1d5d58e17c68a2f319c51e7f938ce6e964498bcc/src/Renci.SshNet/Security/Cryptography/RsaDigitalSignature.cs#L12 - /// - /// With following changes: - /// - OID changed to sha2-256 - /// - hash changed from sha1 to sha2-256 - /// - public class RsaSha256DigitalSignature : CipherDigitalSignature, IDisposable - { - private HashAlgorithm _hash; - - private bool _isDisposed; - - /// Construct with a custom Object Identifier. - /// RSA Key. - public RsaSha256DigitalSignature(RsaWithSha256SignatureKey rsaKey) - : base(new ObjectIdentifier(2, 16, 840, 1, 101, 3, 4, 2, 1), new RsaCipher(rsaKey)) - { - // custom - _hash = SHA256.Create(); - } - - ~RsaSha256DigitalSignature() - { - Dispose(false); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (_isDisposed) - return; - - if (disposing) - { - var hash = _hash; - if (hash != null) - { - hash.Dispose(); - _hash = null; - } - - _isDisposed = true; - } - } - - protected override byte[] Hash(byte[] input) - { - return _hash.ComputeHash(input); - } - } - */ -} diff --git a/src/VsLinuxDebugger/Core/Security/RsaSha256Util.cs b/src/VsLinuxDebugger/Core/Security/RsaSha256Util.cs deleted file mode 100644 index d47672f..0000000 --- a/src/VsLinuxDebugger/Core/Security/RsaSha256Util.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using System.Security.Cryptography; -using Renci.SshNet; -using Renci.SshNet.Common; -using Renci.SshNet.Security; -using Renci.SshNet.Security.Cryptography; -using Renci.SshNet.Security.Cryptography.Ciphers; - -namespace VsLinuxDebugger.Core.Security -{ - /// - /// Utility class which allows ssh.net to connect to servers using ras-sha2-256. - /// - public static class RsaSha256Util - { - /* - /// RSA SHA2 256. - public const string RSA_SHA2_256 = "rsa-sha2-256"; - - /// - /// Converts key file to rsa key with sha2-256 signature - /// Due to lack of constructor: https://github.com/sshnet/SSH.NET/blob/bc99ada7da3f05f50d9379f2644941d91d5bf05a/src/Renci.SshNet/PrivateKeyFile.cs#L86 - /// We do that in place - /// - /// Private key file. - /// Argument Null Exception. - public static void ConvertToKeyWithSha256Signature(PrivateKeyFile keyFile) - { - //// var oldKeyHostAlgorithm = keyFile.HostKey as KeyHostAlgorithm; - var oldKeyHostAlgorithm = keyFile.HostKeyAlgorithms.First(); - if (oldKeyHostAlgorithm == null) - { - throw new ArgumentNullException(nameof(oldKeyHostAlgorithm)); - } - - //// var x = new KeyHostAlgorithm("name", key: null, digitalSignature: new RsaDigitalSignature(null)); - var oldRsaKey = oldKeyHostAlgorithm.Key as RsaKey; - if (oldRsaKey == null) - { - throw new ArgumentNullException(nameof(oldRsaKey)); - } - - var newRsaKey = new RsaWithSha256SignatureKey(oldRsaKey.Modulus, oldRsaKey.Exponent, oldRsaKey.D, oldRsaKey.P, oldRsaKey.Q, - oldRsaKey.InverseQ); - - UpdatePrivateKeyFile(keyFile, newRsaKey); - } - - public static void SetupConnection(ConnectionInfo connection) - { - connection.HostKeyAlgorithms[RSA_SHA2_256] = data => new KeyHostAlgorithm(RSA_SHA2_256, new RsaKey(), data); - } - - private static void UpdatePrivateKeyFile(PrivateKeyFile keyFile, RsaWithSha256SignatureKey key) - { - var keyHostAlgorithm = new KeyHostAlgorithm(key.ToString(), key); - - var hostKeyProperty = typeof(PrivateKeyFile).GetProperty(nameof(PrivateKeyFile.HostKey)); - hostKeyProperty.SetValue(keyFile, keyHostAlgorithm); - - var keyField = typeof(PrivateKeyFile).GetField("_key", BindingFlags.NonPublic | BindingFlags.Instance); - keyField.SetValue(keyFile, key); - } - */ - } -} diff --git a/src/VsLinuxDebugger/Core/Security/RsaWithSha256SignatureKey.cs b/src/VsLinuxDebugger/Core/Security/RsaWithSha256SignatureKey.cs deleted file mode 100644 index 6d2d444..0000000 --- a/src/VsLinuxDebugger/Core/Security/RsaWithSha256SignatureKey.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Renci.SshNet.Common; -using Renci.SshNet.Security; -using Renci.SshNet.Security.Cryptography; - -namespace VsLinuxDebugger.Core.Security -{ - /* - /// RSA With SHA256 Signature Key. - public class RsaWithSha256SignatureKey : RsaKey - { - private RsaSha256DigitalSignature _digitalSignature; - - public RsaWithSha256SignatureKey(BigInteger modulus, BigInteger exponent, BigInteger d, BigInteger p, BigInteger q, BigInteger inverseQ) - : base(modulus, exponent, d, p, q, inverseQ) - { - } - - protected override DigitalSignature DigitalSignature - { - get - { - _digitalSignature ??= new RsaSha256DigitalSignature(this); - return _digitalSignature; - } - } - - public override string ToString() - { - return RsaSha256Util.RSA_SHA2_256; - } - } - */ -} diff --git a/src/VsLinuxDebugger/Core/SshTool.cs b/src/VsLinuxDebugger/Core/SshTool.cs index 8e0badf..ae0e9fa 100644 --- a/src/VsLinuxDebugger/Core/SshTool.cs +++ b/src/VsLinuxDebugger/Core/SshTool.cs @@ -4,13 +4,10 @@ using System.IO; using System.Text.RegularExpressions; using System.Threading.Tasks; -using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; using Renci.SshNet; using Renci.SshNet.Common; -using Renci.SshNet.Security; using SharpCompress.Common; using SharpCompress.Writers; -using VsLinuxDebugger.Core.Security; namespace VsLinuxDebugger.Core { @@ -18,8 +15,8 @@ public class SshTool : IDisposable { private readonly string _tarGzFileName = "vsldBuildContents.tar.gz"; - private bool _isConnected = false; private SshConnectionInfo _info; + private bool _isConnected = false; private ScpClient _scp; private SftpClient _sftp; private SshClient _ssh; @@ -209,7 +206,6 @@ public async Task ConnectAsync() : new SftpClient(_info.Host, _info.Port, _info.UserName, _info.UserPass); _sftp.Connect(); - } catch (Exception) { diff --git a/src/VsLinuxDebugger/VsLinuxDebugger.csproj b/src/VsLinuxDebugger/VsLinuxDebugger.csproj index 05746ec..b1330c8 100644 --- a/src/VsLinuxDebugger/VsLinuxDebugger.csproj +++ b/src/VsLinuxDebugger/VsLinuxDebugger.csproj @@ -53,9 +53,6 @@ - - - From 7adbfdb09b20fe70249f887cd65146edb3a8f19f Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Fri, 8 Mar 2024 09:21:14 -0500 Subject: [PATCH 5/5] Bumped version in manifest to 2.2.0 --- src/VsLinuxDebugger/source.extension.vsixmanifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VsLinuxDebugger/source.extension.vsixmanifest b/src/VsLinuxDebugger/source.extension.vsixmanifest index 5b45ac0..8fbf5cd 100644 --- a/src/VsLinuxDebugger/source.extension.vsixmanifest +++ b/src/VsLinuxDebugger/source.extension.vsixmanifest @@ -4,7 +4,7 @@ xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011"> VS Linux Debugger @@ -14,7 +14,7 @@ ..\..\readme.md ..\..\release-notes.md Resources\TuxDebug.png - debug; build; remote debug; vsdbg; linux; xamarin; rpi; rpi4; remotedebug; remote; debugger; linux debug; net6; dotnet; raspberry pi; ubuntu; + debug; build; remote debug; vsdbg; linux; xamarin; rpi; rpi4; remotedebug; remote; debugger; linux debug; net6; dotnet; raspberry pi; ubuntu; suess; suess-labs; xeno-innovations