aimeast / fxssh Goto Github PK
View Code? Open in Web Editor NEWFxSsh is a lightweight SSH server side application as SSH reinforcement of GitCandy.
License: MIT License
FxSsh is a lightweight SSH server side application as SSH reinforcement of GitCandy.
License: MIT License
Unable to negotiate with 127.0.0.1 port 9999: no matching key exchange method found. Their offer: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
Would be great to add some automated tests to the project, for example, spinning up an SSH server and then using SSH.NET as a client to interact with it.
in Session.SetSocketOptions
in _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
The following exception is thrown:
System.Net.Sockets.SocketException (95): Operation not supported
I got it working by commenting out this line.
dotnet --version gives: 2.1.401
Seems to be a know dotnet issue
https://github.com/dotnet/corefx/issues/28305
Sending data greater then 1024 event cumulatively will cause a unlimited wait.
public void SendData(byte[] data)
{
Contract.Requires(data != null);
if (data.Length == 0)
{
return;
}
var msg = new ChannelDataMessage();
msg.RecipientChannel = ClientChannelId;
var total = (uint)data.Length;
var offset = 0L;
byte[] buf = null;
do
{
var packetSize = Math.Min(Math.Min(ClientWindowSize, ClientMaxPacketSize), total);
// This waits forever?
if (packetSize == 0)
{
_sendingWindowWaitHandle.WaitOne();
continue;
}
if (buf == null || packetSize != buf.Length)
buf = new byte[packetSize];
Array.Copy(data, offset, buf, 0, packetSize);
msg.Data = buf;
_connectionService._session.SendMessage(msg);
ClientWindowSize -= packetSize;
total -= packetSize;
offset += packetSize;
} while (total > 0);
}
As per ssh documentation
The close message can be non-violently to return exit-statuses and acknowledgement of commands.
" When the command running at the other end terminates, the following
message can be sent to return the exit status of the command.
Returning the status is RECOMMENDED. No acknowledgement is sent for
this message. The channel needs to be closed with
SSH_MSG_CHANNEL_CLOSE after this message.
The client MAY ignore these messages.
byte SSH_MSG_CHANNEL_REQUEST
uint32 recipient channel
string "exit-status"
boolean FALSE
uint32 exit_status
The remote command may also terminate violently due to a signal.
Such a condition can be indicated by the following message. A zero
'exit_status' usually means that the command terminated successfully.
"
Suggested fix is to allow for optional parameter in SendClose(uint? exitCode = null) in Channel.cs that dictates whether to "CheckBothClosed()" which will default to true to prevent any breaking change for other projects.
public void SendClose(uint? exitCode = null, bool forceClose = true)
{
if (ServerClosed)
return;
ServerClosed = true;
if (exitCode.HasValue)
_connectionService._session.SendMessage(new ExitStatusMessage { RecipientChannel = ClientChannelId, ExitStatus = exitCode.Value });
_connectionService._session.SendMessage(new ChannelCloseMessage { RecipientChannel = ClientChannelId });
if (forceClose)
{
CheckBothClosed();
}
}
I will submit a PR with the suggested fix.
Version 1.0.0 on NuGet is quite old - would be great to release a new version so we can benefit from the changes and fixes that have been made since then.
Any interest in publishing a new version to pick up the dev branch changes submitted after 1.1.1 was released to nuget? There are some good changes that are of interest to us in the handful of changes made after Jan 19, 2019.
My SSH client is PuTTY.
When window width added, the output content still wrap line by old width.
When window height added, after output the cursor is no followed to bottom of window, scroll are broken.
Hi, do you plan to add any feature under subsystem? at least an echo service? to act as a honeypot or similar functionality?
Cheers, loved it so far
So I can remove the warning disable: 8002
Looking for sample ssh server code on FxSsh.PwAuth, do you have any to share?
The SshServer has AddHostKey method, I want to add a ClearHostKey to support change the host key during the SshServer running. Is it possible?
The SSH_MSG_UNIMPLEMENTED handler currently sends unimplemented message back:
Lines 600 to 602 in dbacd36
It's weird behavior. openssh
, for example, just logs this message without doing anything with it:
I try use RSACryptoServiceProvider ToXmlString, its no work.
I try use PuTTY Key Generator and copy private key, its no work too.
How can i generate my own host key?
It's in Session
class.
If Disconnect
overload without parameters is called, then Disconnected
event will be called twice:
https://github.com/Aimeast/FxSsh/blob/dev/FxSsh/Session.cs#L151
https://github.com/Aimeast/FxSsh/blob/dev/FxSsh/Session.cs#L171
Hi,
I tried to implement a SFTP Subsystem beneath FxSsh. It works as expected but I noticed that the timeout for read seems to be 30 seconds. I couldn't find anything about timeouts in the RFC and all the SFTP Clients I tried (FileZilla, WinScp and even putty) are reporting that the server unexpectedly closed the connection when it's idle for 30 seconds.
"Socket operation has timed out after 30000 milliseconds."
It would be great if this timeout can be made configurable or even be disabled.
Or maybe I'm just missing something?
It is found a problem when test the #9. PuTTY may throw Incorrect MAC received on packet during shell
session.
Hello, I'm using a connection with OpenSSH Pty console type.
Running version 1.1.1 from NuGet
I don't know if this is related to a idle timeout, as the disconnect seems to happen when there is no activity, not so sure. May be this diagnostics (-vvv) makes more sense to someone else than me.
debug3: send packet: type 1
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i0/0 o0/0 fd 4/5 cc -1)
Connection to localhost closed by remote host.
Connection to localhost closed.
Transferred: sent 8584, received 56784 bytes, in 114.3 seconds
Bytes per second: sent 75.1, received 496.6
debug1: Exit status -1
also Session.Disconnected
event is fired on the server.
Hello,
can I use this project to implement a reverse tunneling to my client?
Reading this instructions: https://www.howtoforge.com/reverse-ssh-tunneling , I can connect to the FxSsh server using from my "remote client":
ssh -R 10000:localhost:22 michele@publicIP
But when I connect from to my PublicIP at port 10000 there is no channel opened.
I saw from the sources the service_TcpForwardRequest function, but I cannot figure out how to make it execute from a ssh client...
Can you pls help?
Thanks,
Michele
Result of signature verification in public key auth is ignored. Because of that server will accept any signature effectively removing need of private key for auth. This allows user to auth using ONLY trusted public key.
Just dropping a note here that FxSsh probably needs to adopt the strict key exchange mitigation mentioned in https://terrapin-attack.com/ or it will be blocked by modern SSH clients/servers in the near future. I haven't looked into the technical details yet.
Hello,
Nice lib, but it really needs upgrade in compatibility (ECC)!!
And when you guys do implement it, please use bouncy castle lib not a CNG from net core as CNG is not available on linux only on windows platform. i don't mind little dependency as long as it works on every platform :)
如题
First, the server can not use the .ppk public key generated by puttygen.
Second, I use the key in the example and use putty connect to it, but I met this error:
Unknown request type: pty-req.
It seems the method 'HandleMessage' in file ConnectionService.cs not process pty-req:
private void HandleMessage(ChannelRequestMessage message) { switch (message.RequestType) { case "exec": var msg = Message.LoadFrom<CommandRequestMessage>(message); HandleMessage(msg); break; default: if (message.WantReply) _session.SendMessage(new ChannelFailureMessage { RecipientChannel = FindChannelByServerId<Channel>(message.RecipientChannel).ClientChannelId }); throw new SshConnectionException(string.Format("Unknown request type: {0}.", message.RequestType)); } }
Hi,
I'd like to make some contributions to FxSsh, do you have any requirements for PRs?
Kind Regards,
Chris
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.