mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 14:07:46 +08:00
Merge pull request #2064 from merarischroeder/503_ssh-execute-single-command-after-login
503 SSH Execute a single command after login
This commit is contained in:
@@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
- #283: Support for native PowerShell remoting as new protocol
|
||||
- #1850: Minify config xml
|
||||
- #1516: added API to access credential vault (Thycotic Secret Server) by specifying SSAPI:ID as username
|
||||
- #503: SSH Execute a single command after login
|
||||
### Changed
|
||||
- #2022: Replaced CefSharp with WebView2
|
||||
- #2014: Revised icons
|
||||
|
||||
@@ -128,6 +128,10 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Csv
|
||||
? connectionCsv[headers.IndexOf("SSHTunnelConnectionName")]
|
||||
: "";
|
||||
|
||||
connectionRecord.OpeningCommand = headers.Contains("OpeningCommand")
|
||||
? connectionCsv[headers.IndexOf("OpeningCommand")]
|
||||
: "";
|
||||
|
||||
connectionRecord.PuttySession = headers.Contains("PuttySession")
|
||||
? connectionCsv[headers.IndexOf("PuttySession")]
|
||||
: "";
|
||||
@@ -536,6 +540,12 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Csv
|
||||
connectionRecord.Inheritance.SSHTunnelConnectionName = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritOpeningCommand"))
|
||||
{
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritOpeningCommand")], out bool value))
|
||||
connectionRecord.Inheritance.OpeningCommand = value;
|
||||
}
|
||||
|
||||
if (headers.Contains("InheritSSHOptions"))
|
||||
{
|
||||
if (bool.TryParse(connectionCsv[headers.IndexOf("InheritSSHOptions")], out bool value))
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Csv
|
||||
if (_saveFilter.SaveDomain)
|
||||
sb.Append("Domain;");
|
||||
|
||||
sb.Append("Hostname;Port;VmId;Protocol;SSHTunnelConnectionName;SSHOptions;PuttySession;ConnectToConsole;UseCredSsp;UseVmId;UseEnhancedMode;RenderingEngine;RDPAuthenticationLevel;" +
|
||||
sb.Append("Hostname;Port;VmId;Protocol;SSHTunnelConnectionName;OpeningCommand;SSHOptions;PuttySession;ConnectToConsole;UseCredSsp;UseVmId;UseEnhancedMode;RenderingEngine;RDPAuthenticationLevel;" +
|
||||
"LoadBalanceInfo;Colors;Resolution;AutomaticResize;DisplayWallpaper;DisplayThemes;EnableFontSmoothing;EnableDesktopComposition;DisableFullWindowDrag;DisableMenuAnimations;DisableCursorShadow;DisableCursorBlinking;" +
|
||||
"CacheBitmaps;RedirectDiskDrives;RedirectPorts;RedirectPrinters;RedirectClipboard;RedirectSmartCards;RedirectSound;RedirectKeys;" +
|
||||
"PreExtApp;PostExtApp;MacAddress;UserField;ExtApp;Favorite;VNCCompression;VNCEncoding;VNCAuthMode;VNCProxyType;VNCProxyIP;" +
|
||||
@@ -120,6 +120,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Csv
|
||||
.Append(FormatForCsv(con.VmId))
|
||||
.Append(FormatForCsv(con.Protocol))
|
||||
.Append(FormatForCsv(con.SSHTunnelConnectionName))
|
||||
.Append(FormatForCsv(con.OpeningCommand))
|
||||
.Append(FormatForCsv(con.SSHOptions))
|
||||
.Append(FormatForCsv(con.PuttySession))
|
||||
.Append(FormatForCsv(con.UseConsoleSession))
|
||||
@@ -196,6 +197,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Csv
|
||||
.Append(FormatForCsv(con.Inheritance.Port))
|
||||
.Append(FormatForCsv(con.Inheritance.Protocol))
|
||||
.Append(FormatForCsv(con.Inheritance.SSHTunnelConnectionName))
|
||||
.Append(FormatForCsv(con.Inheritance.OpeningCommand))
|
||||
.Append(FormatForCsv(con.Inheritance.SSHOptions))
|
||||
.Append(FormatForCsv(con.Inheritance.PuttySession))
|
||||
.Append(FormatForCsv(con.Inheritance.RedirectDiskDrives))
|
||||
|
||||
@@ -91,6 +91,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
connectionInfo.UseEnhancedMode = (bool)dataRow["UseEnhancedMode"];
|
||||
connectionInfo.Protocol = (ProtocolType)Enum.Parse(typeof(ProtocolType), (string)dataRow["Protocol"]);
|
||||
connectionInfo.SSHTunnelConnectionName = (string)dataRow["SSHTunnelConnectionName"];
|
||||
connectionInfo.OpeningCommand = (string)dataRow["OpeningCommand"];
|
||||
connectionInfo.SSHOptions = (string)dataRow["SSHOptions"];
|
||||
connectionInfo.PuttySession = (string)dataRow["PuttySession"];
|
||||
connectionInfo.Port = (int)dataRow["Port"];
|
||||
@@ -188,6 +189,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
connectionInfo.Inheritance.Port = (bool)dataRow["InheritPort"];
|
||||
connectionInfo.Inheritance.Protocol = (bool)dataRow["InheritProtocol"];
|
||||
connectionInfo.Inheritance.SSHTunnelConnectionName = (bool)dataRow["InheritSSHTunnelConnectionName"];
|
||||
connectionInfo.Inheritance.OpeningCommand = (bool)dataRow["InheritOpeningCommand"];
|
||||
connectionInfo.Inheritance.SSHOptions = (bool)dataRow["InheritSSHOptions"];
|
||||
connectionInfo.Inheritance.PuttySession = (bool)dataRow["InheritPuttySession"];
|
||||
connectionInfo.Inheritance.RedirectDiskDrives = (bool)dataRow["InheritRedirectDiskDrives"];
|
||||
|
||||
@@ -516,6 +516,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
dataRow["VmId"] = connectionInfo.VmId;
|
||||
dataRow["Protocol"] = connectionInfo.Protocol;
|
||||
dataRow["SSHTunnelConnectionName"] = connectionInfo.SSHTunnelConnectionName;
|
||||
dataRow["OpeningCommand"] = connectionInfo.OpeningCommand;
|
||||
dataRow["SSHOptions"] = connectionInfo.SSHOptions;
|
||||
dataRow["PuttySession"] = connectionInfo.PuttySession;
|
||||
dataRow["Port"] = connectionInfo.Port;
|
||||
@@ -596,6 +597,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
dataRow["InheritPort"] = connectionInfo.Inheritance.Port;
|
||||
dataRow["InheritProtocol"] = connectionInfo.Inheritance.Protocol;
|
||||
dataRow["InheritSSHTunnelConnectionName"] = connectionInfo.Inheritance.SSHTunnelConnectionName;
|
||||
dataRow["InheritOpeningCommand"] = connectionInfo.Inheritance.OpeningCommand;
|
||||
dataRow["InheritSSHOptions"] = connectionInfo.Inheritance.SSHOptions;
|
||||
dataRow["InheritPuttySession"] = connectionInfo.Inheritance.PuttySession;
|
||||
dataRow["InheritRedirectDiskDrives"] = connectionInfo.Inheritance.RedirectDiskDrives;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Security;
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.Connection;
|
||||
@@ -66,6 +66,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
element.Add(new XAttribute("Hostname", connectionInfo.Hostname));
|
||||
element.Add(new XAttribute("Protocol", connectionInfo.Protocol));
|
||||
element.Add(new XAttribute("SSHTunnelConnectionName", connectionInfo.SSHTunnelConnectionName));
|
||||
element.Add(new XAttribute("OpeningCommand", connectionInfo.OpeningCommand));
|
||||
element.Add(new XAttribute("SSHOptions", connectionInfo.SSHOptions));
|
||||
element.Add(new XAttribute("PuttySession", connectionInfo.PuttySession));
|
||||
element.Add(new XAttribute("Port", connectionInfo.Port));
|
||||
@@ -168,6 +169,8 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
element.Add(new XAttribute("InheritProtocol", inheritance.Protocol.ToString().ToLowerInvariant()));
|
||||
if (inheritance.SSHTunnelConnectionName)
|
||||
element.Add(new XAttribute("InheritSSHTunnelConnectionName", inheritance.SSHTunnelConnectionName.ToString().ToLowerInvariant()));
|
||||
if (inheritance.OpeningCommand)
|
||||
element.Add(new XAttribute("InheritOpeningCommand", inheritance.OpeningCommand.ToString().ToLowerInvariant()));
|
||||
if (inheritance.SSHOptions)
|
||||
element.Add(new XAttribute("InheritSSHOptions", inheritance.SSHOptions.ToString().ToLowerInvariant()));
|
||||
if (inheritance.PuttySession)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Security;
|
||||
using System.Xml.Linq;
|
||||
using mRemoteNG.App;
|
||||
@@ -76,6 +76,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
element.Add(new XAttribute("Protocol", connectionInfo.Protocol));
|
||||
element.Add(new XAttribute("RdpVersion", connectionInfo.RdpVersion.ToString().ToLowerInvariant()));
|
||||
element.Add(new XAttribute("SSHTunnelConnectionName", connectionInfo.SSHTunnelConnectionName));
|
||||
element.Add(new XAttribute("OpeningCommand", connectionInfo.OpeningCommand));
|
||||
element.Add(new XAttribute("SSHOptions", connectionInfo.SSHOptions));
|
||||
element.Add(new XAttribute("PuttySession", connectionInfo.PuttySession));
|
||||
element.Add(new XAttribute("Port", connectionInfo.Port));
|
||||
@@ -194,6 +195,8 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
element.Add(new XAttribute("InheritRdpVersion", inheritance.RdpVersion.ToString().ToLowerInvariant()));
|
||||
if (inheritance.SSHTunnelConnectionName)
|
||||
element.Add(new XAttribute("InheritSSHTunnelConnectionName", inheritance.SSHTunnelConnectionName.ToString().ToLowerInvariant()));
|
||||
if (inheritance.OpeningCommand)
|
||||
element.Add(new XAttribute("InheritOpeningCommand", inheritance.OpeningCommand.ToString().ToLowerInvariant()));
|
||||
if (inheritance.SSHOptions)
|
||||
element.Add(new XAttribute("InheritSSHOptions", inheritance.SSHOptions.ToString().ToLowerInvariant()));
|
||||
if (inheritance.PuttySession)
|
||||
|
||||
@@ -539,6 +539,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
connectionInfo.UseEnhancedMode = xmlnode.GetAttributeAsBool("UseEnhancedMode");
|
||||
connectionInfo.RdpVersion = xmlnode.GetAttributeAsEnum("RdpVersion", RdpVersion.Highest);
|
||||
connectionInfo.SSHTunnelConnectionName = xmlnode.GetAttributeAsString("SSHTunnelConnectionName");
|
||||
connectionInfo.OpeningCommand = xmlnode.GetAttributeAsString("OpeningCommand");
|
||||
connectionInfo.SSHOptions = xmlnode.GetAttributeAsString("SSHOptions");
|
||||
connectionInfo.StartProgram = xmlnode.GetAttributeAsString("StartProgram");
|
||||
connectionInfo.DisableFullWindowDrag = xmlnode.GetAttributeAsBool("DisableFullWindowDrag");
|
||||
@@ -552,6 +553,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
connectionInfo.Inheritance.VmId = xmlnode.GetAttributeAsBool("InheritVmId");
|
||||
connectionInfo.Inheritance.UseEnhancedMode = xmlnode.GetAttributeAsBool("InheritUseEnhancedMode");
|
||||
connectionInfo.Inheritance.SSHTunnelConnectionName = xmlnode.GetAttributeAsBool("InheritSSHTunnelConnectionName");
|
||||
connectionInfo.Inheritance.OpeningCommand = xmlnode.GetAttributeAsBool("InheritOpeningCommand");
|
||||
connectionInfo.Inheritance.SSHOptions = xmlnode.GetAttributeAsBool("InheritSSHOptions");
|
||||
connectionInfo.Inheritance.DisableFullWindowDrag = xmlnode.GetAttributeAsBool("InheritDisableFullWindowDrag");
|
||||
connectionInfo.Inheritance.DisableMenuAnimations = xmlnode.GetAttributeAsBool("InheritDisableMenuAnimations");
|
||||
|
||||
@@ -77,6 +77,7 @@ namespace mRemoteNG.Connection
|
||||
private string _preExtApp;
|
||||
private string _postExtApp;
|
||||
private string _macAddress;
|
||||
private string _openingCommand;
|
||||
private string _userField;
|
||||
private string _startProgram;
|
||||
private bool _favorite;
|
||||
@@ -211,6 +212,16 @@ namespace mRemoteNG.Connection
|
||||
get => GetPropertyValue("SSHTunnelConnectionName", _sshTunnelConnectionName).Trim();
|
||||
set => SetField(ref _sshTunnelConnectionName, value?.Trim(), "SSHTunnelConnectionName");
|
||||
}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory(nameof(Language.Miscellaneous), 7),
|
||||
LocalizedAttributes.LocalizedDisplayName(nameof(Language.OpeningCommand)),
|
||||
LocalizedAttributes.LocalizedDescription(nameof(Language.PropertyDescriptionOpeningCommand)),
|
||||
AttributeUsedInProtocol(ProtocolType.SSH1, ProtocolType.SSH2)]
|
||||
public virtual string OpeningCommand
|
||||
{
|
||||
get => GetPropertyValue("OpeningCommand", _openingCommand);
|
||||
set => SetField(ref _openingCommand, value, "OpeningCommand");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Protocol
|
||||
|
||||
@@ -92,6 +92,15 @@ namespace mRemoteNG.Connection
|
||||
[Browsable(true)]
|
||||
public bool SSHTunnelConnectionName { get; set; }
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory(nameof(Language.Connection), 3),
|
||||
LocalizedAttributes.LocalizedDisplayNameInheritAttribute(nameof(Language.OpeningCommand)),
|
||||
LocalizedAttributes.LocalizedDescriptionInheritAttribute(nameof(Language.PropertyDescriptionOpeningCommand)),
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]
|
||||
[Browsable(true)]
|
||||
public bool OpeningCommand { get; set; }
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protocol
|
||||
|
||||
@@ -203,6 +203,10 @@ namespace mRemoteNG.Connection.Protocol
|
||||
string.Format(Language.PanelHandle,
|
||||
InterfaceControl.Parent.Handle), true);
|
||||
|
||||
NativeMethods.SetForegroundWindow(PuttyHandle);
|
||||
var finalCommand = InterfaceControl.Info.OpeningCommand.TrimEnd() + "\n";
|
||||
SendKeys.SendWait(finalCommand);
|
||||
|
||||
Resize(this, new EventArgs());
|
||||
base.Connect();
|
||||
return true;
|
||||
|
||||
1422
mRemoteNG/Language/Language.Designer.cs
generated
1422
mRemoteNG/Language/Language.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1861,7 +1861,6 @@ mRemoteNG will now quit and begin with the installation.</value>
|
||||
</data>
|
||||
<data name="CredentialUnavailable" xml:space="preserve">
|
||||
<value>Credential not available</value>
|
||||
|
||||
</data>
|
||||
<data name="OptionsThemeDeleteConfirmation" xml:space="preserve">
|
||||
<value>Do you really want to delete the theme?</value>
|
||||
@@ -2180,4 +2179,10 @@ Nightly Channel includes Alphas, Betas & Release Candidates.</value>
|
||||
<data name="SmartCard" xml:space="preserve">
|
||||
<value>SmartCard</value>
|
||||
</data>
|
||||
<data name="OpeningCommand" xml:space="preserve">
|
||||
<value>Opening Command</value>
|
||||
</data>
|
||||
<data name="PropertyDescriptionOpeningCommand" xml:space="preserve">
|
||||
<value>A command to run on the remote server after successfully connecting.</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user