-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
150 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// This file is part of Tmds.Ssh which is released under MIT. | ||
// See file LICENSE for full license details. | ||
|
||
namespace Tmds.Ssh; | ||
|
||
public sealed class NoCredential : Credential | ||
{ | ||
public NoCredential() | ||
{ } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// This file is part of Tmds.Ssh which is released under MIT. | ||
// See file LICENSE for full license details. | ||
|
||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Tmds.Ssh; | ||
|
||
partial class UserAuthentication | ||
{ | ||
// https://datatracker.ietf.org/doc/html/rfc4252 - The "none" Authentication Request | ||
public sealed class NoneAuth | ||
{ | ||
public static async Task<AuthResult> TryAuthenticate(UserAuthContext context, SshConnectionInfo connectionInfo, ILogger<SshClient> logger, CancellationToken ct) | ||
{ | ||
context.StartAuth(AlgorithmNames.None); | ||
|
||
logger.NoneAuth(); | ||
|
||
{ | ||
using var userAuthMsg = CreateNoneRequestMessage(context.SequencePool, context.UserName); | ||
await context.SendPacketAsync(userAuthMsg.Move(), ct).ConfigureAwait(false); | ||
} | ||
|
||
return await context.ReceiveAuthResultAsync(ct).ConfigureAwait(false); | ||
} | ||
|
||
private static Packet CreateNoneRequestMessage(SequencePool sequencePool, string userName) | ||
{ | ||
using var packet = sequencePool.RentPacket(); | ||
var writer = packet.GetWriter(); | ||
writer.WriteMessageId(MessageId.SSH_MSG_USERAUTH_REQUEST); | ||
writer.WriteString(userName); | ||
writer.WriteString("ssh-connection"); | ||
writer.WriteString("none"); | ||
return packet.Move(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Xunit; | ||
|
||
namespace Tmds.Ssh.Tests; | ||
|
||
[Collection(nameof(NoneAuthSshServerCollection))] | ||
public class NoneAuthenticationTests | ||
{ | ||
private readonly NoneAuthSshServer _sshServer; | ||
|
||
public NoneAuthenticationTests(NoneAuthSshServer sshServer) | ||
{ | ||
_sshServer = sshServer; | ||
} | ||
|
||
[Fact] | ||
public async Task Success() | ||
{ | ||
var settings = new SshClientSettings(_sshServer.Destination) | ||
{ | ||
UserKnownHostsFilePaths = [ _sshServer.KnownHostsFilePath ], | ||
Credentials = [ new NoCredential() ] | ||
}; | ||
|
||
using var client = new SshClient(settings); | ||
|
||
await client.ConnectAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters