Comments (15)
from ssh.net.
On what line would it actually block?
Can you build SSH.NET from source and do some troubleshooting yourself, or can you provide me access to a Cisco ASA that is not in use?
from ssh.net.
Hello. I have already downloaded the source and can do some simple troubleshooting tommorow. I will look into it i maybe have ASA we can test on.
Also thanks for the library it works very well on the Catalysts switches.
from ssh.net.
Hello. Again after some stepping the command highlighted is where it hangs for eternity.
from ssh.net.
Have fixed an asa you can test on. Should i send the login information to the email on your profile?
from ssh.net.
Yes, that's ok. I'm not sure I'll have time today, but I'll look into it asap.
Please include the command that you were trying to execute as well.
Thanks!
from ssh.net.
I've exactly the same problem when I try acces to Mitrastar FTTH router.
from ssh.net.
The problem with the ASA was that it does not properly support the "exec" channel request message.
Perhaps this is a scenario that the ASA - and similar devices - do not want to support.
Instead of executing the command you specify, it:
- creates a shell
- writes the command to the shell
- continues waiting for input
I've supplied @ravelund with a solution offline, which uses our ShellStream - with its Expect capabilities - instead.
from ssh.net.
@drieseng seems to be correct.
Found this via google:
http://www.carbon60.com/it-advice/powershell-ssh-module-nonstandard-devices-like-cisco-asa
Sounds like you have to work with Shell + Expect.
from ssh.net.
Also with @drieseng input i have created this function:
/// <summary>
/// Execute a command on a host using ssh
/// </summary>
/// <param name="host">Ip address or Hostname</param>
/// <param name="port">Ssh port</param>
/// <param name="username">Username</param>
/// <param name="password">Password</param>
/// <param name="commands">Commands to execute</param>
/// <param name="sendUsernameAndPasswordAsCommand">If set to true the query will send the username and password before running main command. For cisco catalyst and Firewalls False.</param>
/// <returns>String with line shifts</returns>
public string ExecuteCommandSsh(string host,int port, string username, string password, string[] commands, bool sendUsernameAndPasswordAsCommand)
{
string returnString = "";
try
{
using (var client = new SshClient(host, port, username, password))
{
//Create the command string
string command = "";
foreach (var com in commands)
{
command += com + "\n";
}
client.Connect();
SshCommand runcommand = client.CreateCommand(command);
if (sendUsernameAndPasswordAsCommand)
{
runcommand = client.CreateCommand($"{username}\n{password}\n{command}");
}
runcommand.CommandTimeout = CommandTimeOut;
try
{
runcommand.Execute();
returnString = runcommand.Result;
}
catch (SshOperationTimeoutException)
{
ErrorMessage += "ExecuteCommandSsh: Command timeout.";
returnString = runcommand.Result;
}
client.Disconnect();
}
}
catch (Exception e)
{
DidThrowError = true;
ErrorMessage += $"ExecuteCommandSsh Exception: {e.ToString()}";
}
return returnString;
} //ExecuteCommandSsh end
By suppling the commands string array with
enable
"enablepassword"
terminal pager 0
sh ver
sh run
The terminal pager 0 command on the asa skips the more question. And this works.
The only - here is that you have to wait for the command to timeout.
I have set the timeout to 30 seconds at this moment.
from ssh.net.
I actually sent you a basic implemention that uses ShellStream and Except.
If you prefer the code above, then that's fine by me.
from ssh.net.
Would you mind posting the workaround solution, @drieseng ? I'm encountering what looks like the same issue, but working from a prebuilt dll that I don't have the luxury of picking apart in the debugger. I'm going to try @ravelund 's solution for now, but if there's a more correct/compact implementation, that would be useful.
from ssh.net.
from ssh.net.
Thanks! Trying an explicitly constructed command with a timeout as per the first example still jammed up for me for the duration of the timeout, and returned without apparently having executed anything. It's nice to have the Expect solution on record as an alternative.
I ultimately sorted my use case out by realizing there was a dedicated SshNet.Sftp module already available and I didn't need to be doing commands manually to begin with. I would have gone so far as questioning my use of ftp syntax/protocol, except things as simple as a cd or a pwd were also jamming.
from ssh.net.
@ravelund the second solution worked for me, Thank a lot!!
from ssh.net.
Related Issues (20)
- RSA Cipher Encrypt method may truncate leading byte from created Signature, if that byte is 00, causing server validation failure HOT 2
- Q. Any chance this would work from a web-assembly app? HOT 2
- Multifactor SSH Client HOT 4
- SftpClient: how to resume upload/download? I.e. process SFTP command 'reput' & 'reget' HOT 2
- Update from 2020.0.2 to 2024.0.0, could not load System.Security.Cryptography.ECCurve HOT 2
- SSH.Net 2024.0.0 works for UWP but does not work for Android and iOS HOT 1
- SftpClient.ConnectAsync hangs HOT 5
- System.NotSupportedException: Request 'ping' is not supported. HOT 6
- Missing async methods.
- Support creating shell without PTY HOT 3
- SftpClient upload file doesn't work in UWP and Console applications. HOT 2
- System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond HOT 1
- Typo: SftpFileSytemInformation
- New_key
- @Xtgdominated HOT 1
- Send CTRL+S over ShellStream HOT 1
- stream.SetLength() not truncating file HOT 3
- ED25519 key - Client encryption algorithm not found HOT 2
- SftpClient: Stale file handle
- Any plan for key exchange RSA-based? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ssh.net.