Skip to content

Commit aff1a58

Browse files
Merge branch 'develop' into develop
2 parents 2f7227b + 9593e87 commit aff1a58

File tree

138 files changed

+16144
-3505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+16144
-3505
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Private keys can be encrypted using one of the following cipher methods:
117117
## Framework Support
118118
**SSH.NET** supports the following target frameworks:
119119
* .NETFramework 4.6.2 (and higher)
120-
* .NET Standard 2.0
120+
* .NET Standard 2.0 and 2.1
121121
* .NET 6 (and higher)
122122

123123
## Usage

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ build:
99

1010
test_script:
1111
- cmd: >-
12-
vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net462\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration&TestCategory!=LongRunning" --blame
12+
vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net462\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration" --blame
1313
14-
vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net7.0\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration&TestCategory!=LongRunning" --blame
14+
vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net7.0\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration" --blame

build/build.proj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
<OutputDirectory>Renci.SshNet\bin\$(Configuration)\netstandard2.0</OutputDirectory>
2626
<Moniker>netstandard2.0</Moniker>
2727
</TargetFrameworkModern>
28+
<TargetFrameworkModern Include=".NETStandard 2.1">
29+
<OutputDirectory>Renci.SshNet\bin\$(Configuration)\netstandard2.1</OutputDirectory>
30+
<Moniker>netstandard2.1</Moniker>
31+
</TargetFrameworkModern>
2832
<TargetFrameworkModern Include=".NET 6.0">
2933
<OutputDirectory>Renci.SshNet\bin\$(Configuration)\net6.0</OutputDirectory>
3034
<Moniker>net6.0</Moniker>

build/nuget/SSH.NET.nuspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<group targetFramework="net462" />
2020
<group targetFramework="netstandard2.0">
2121
<dependency id="SshNet.Security.Cryptography" version="[1.3.0]" />
22+
</group>
23+
<group targetFramework="netstandard2.1">
24+
<dependency id="SshNet.Security.Cryptography" version="[1.3.0]" />
2225
</group>
2326
<group targetFramework="net6.0">
2427
<dependency id="SshNet.Security.Cryptography" version="[1.3.0]" />
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[*.cs]
2+
3+
#### SYSLIB diagnostics ####
4+
5+
# SYSLIB1045: Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time
6+
#
7+
# TODO: Remove this when https://github.com/sshnet/SSH.NET/issues/1131 is implemented.
8+
dotnet_diagnostic.SYSLIB1045.severity = none
9+
10+
### StyleCop Analyzers rules ###
11+
12+
#### .NET Compiler Platform analysers rules ####
13+
14+
# IDE0007: Use var instead of explicit type
15+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0007
16+
dotnet_diagnostic.IDE0007.severity = suggestion
17+
18+
# IDE0028: Use collection initializers
19+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0028
20+
dotnet_diagnostic.IDE0028.severity = suggestion
21+
22+
# IDE0058: Remove unnecessary expression value
23+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0058
24+
dotnet_diagnostic.IDE0058.severity = suggestion
25+
26+
# IDE0059: Remove unnecessary value assignment
27+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0059
28+
dotnet_diagnostic.IDE0059.severity = suggestion
29+
30+
# IDE0230: Use UTF-8 string literal
31+
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0230
32+
dotnet_diagnostic.IDE0230.severity = suggestion
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TestResults/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<system.diagnostics>
4+
<trace autoflush="true"/>
5+
<sources>
6+
<source name="SshNet.Logging" switchName="SshNetSwitch" switchType="System.Diagnostics.SourceSwitch">
7+
<listeners>
8+
<!--<add name="SshDotNetTraceFile" />-->
9+
<!--<add name="Console"/>-->
10+
</listeners>
11+
</source>
12+
</sources>
13+
<switches>
14+
<add name="SshNetSwitch" value="Verbose"/>
15+
</switches>
16+
<sharedListeners>
17+
<add name="SshDotNetTraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="SshNetTrace.log">
18+
<!--<filter type="System.Diagnostics.EventTypeFilter" initializeData="Warning" />-->
19+
</add>
20+
<add name="Console" type="System.Diagnostics.ConsoleTraceListener" traceOutputOptions="DateTime,Timestamp,ThreadId"/>
21+
</sharedListeners>
22+
</system.diagnostics>
23+
</configuration>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
namespace Renci.SshNet.IntegrationTests
2+
{
3+
public class AuthenticationMethodFactory
4+
{
5+
public PasswordAuthenticationMethod CreatePowerUserPasswordAuthenticationMethod()
6+
{
7+
var user = Users.Admin;
8+
return new PasswordAuthenticationMethod(user.UserName, user.Password);
9+
}
10+
11+
public PrivateKeyAuthenticationMethod CreateRegularUserPrivateKeyAuthenticationMethod()
12+
{
13+
var privateKeyFile = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_rsa");
14+
return new PrivateKeyAuthenticationMethod(Users.Regular.UserName, privateKeyFile);
15+
}
16+
17+
public PrivateKeyAuthenticationMethod CreateRegularUserMultiplePrivateKeyAuthenticationMethod()
18+
{
19+
var privateKeyFile1 = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_rsa");
20+
var privateKeyFile2 = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_rsa");
21+
return new PrivateKeyAuthenticationMethod(Users.Regular.UserName, privateKeyFile1, privateKeyFile2);
22+
}
23+
24+
public PrivateKeyAuthenticationMethod CreateRegularUserPrivateKeyWithPassPhraseAuthenticationMethod()
25+
{
26+
var privateKeyFile = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_rsa_with_pass", "tester");
27+
return new PrivateKeyAuthenticationMethod(Users.Regular.UserName, privateKeyFile);
28+
}
29+
30+
public PrivateKeyAuthenticationMethod CreateRegularUserPrivateKeyWithEmptyPassPhraseAuthenticationMethod()
31+
{
32+
var privateKeyFile = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_rsa_with_pass", null);
33+
return new PrivateKeyAuthenticationMethod(Users.Regular.UserName, privateKeyFile);
34+
}
35+
36+
public PrivateKeyAuthenticationMethod CreateRegularUserPrivateKeyAuthenticationMethodWithBadKey()
37+
{
38+
var privateKeyFile = GetPrivateKey("Renci.SshNet.IntegrationTests.resources.client.id_noaccess.rsa");
39+
return new PrivateKeyAuthenticationMethod(Users.Regular.UserName, privateKeyFile);
40+
}
41+
42+
public PasswordAuthenticationMethod CreateRegulatUserPasswordAuthenticationMethod()
43+
{
44+
return new PasswordAuthenticationMethod(Users.Regular.UserName, Users.Regular.Password);
45+
}
46+
47+
public PasswordAuthenticationMethod CreateRegularUserPasswordAuthenticationMethodWithBadPassword()
48+
{
49+
return new PasswordAuthenticationMethod(Users.Regular.UserName, "xxx");
50+
}
51+
52+
public KeyboardInteractiveAuthenticationMethod CreateRegularUserKeyboardInteractiveAuthenticationMethod()
53+
{
54+
var keyboardInteractive = new KeyboardInteractiveAuthenticationMethod(Users.Regular.UserName);
55+
keyboardInteractive.AuthenticationPrompt += (sender, args) =>
56+
{
57+
foreach (var authenticationPrompt in args.Prompts)
58+
{
59+
authenticationPrompt.Response = Users.Regular.Password;
60+
}
61+
};
62+
return keyboardInteractive;
63+
}
64+
65+
private PrivateKeyFile GetPrivateKey(string resourceName, string passPhrase = null)
66+
{
67+
using (var stream = GetResourceStream(resourceName))
68+
{
69+
return new PrivateKeyFile(stream, passPhrase);
70+
}
71+
}
72+
73+
private Stream GetResourceStream(string resourceName)
74+
{
75+
var type = GetType();
76+
var resourceStream = type.Assembly.GetManifestResourceStream(resourceName);
77+
if (resourceStream == null)
78+
{
79+
throw new ArgumentException($"Resource '{resourceName}' not found in assembly '{type.Assembly.FullName}'.", nameof(resourceName));
80+
}
81+
return resourceStream;
82+
}
83+
}
84+
}

0 commit comments

Comments
 (0)