Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Shell functionlity

$
0
0
supermanSC wrote:
I'm trying to get this working on a Cisco 65xx switch, and can't seem to get past the enable password prompt.  Oleg, if you're not familiar with Cisco, once you connect using the primary username/password, you need to issue the "enable" command to gain some elevated access levels. Once that's issued, the router will respond with a "Password: " prompt, which requires a password to be entered.  For whatever reason, if I read to the end of the stream prior to entering a password, it's like something is either being entered, or a linefeed is sent across, in which case the Cisco replies with "Bad Password".  Here's the small routine I'm testing with:     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Using client = New SshClient("1.1.1.1", "username", "password")            client.Connect()            Using sshStream = client.CreateShellStream("dumb", 80, 24, 800, 600, 1024)                Dim reader = New StreamReader(sshStream)                Dim writer = New StreamWriter(sshStream)                writer.AutoFlush = True                While sshStream.Length = 0                    Thread.Sleep(500)                End While                Response.Write(reader.ReadToEnd)                writer.WriteLine("enable")                While sshStream.Length = 0                    Thread.Sleep(500)                End While                Response.Write(reader.ReadToEnd.ToString.Replace(vbCrLf, "<BR>"))            End Using            client.Disconnect()        End Using    End Sub   ----   Here's what's returned: test_6506>enablePassword: <--------------- I need to send a password here, yet something is being automatically sent in it's place.% Access deniedtest_6506>
I banged my head on this for a couple of days. I was also using the library to manage cisco routers. SharpSSH worked perfectly fine, but I couldn't get the expect function work correctly in SSH.NET.

After re-reading this thread multiple times, this post got me thinking that there had to be something different between SharpSSH's writeline method and SSH.NET's.

After looking at both library's source I found that SharpSSH is only sending a \r where SSH.NET is sending \r\n. The Cisco's are interpreting the \r\n as a double enter key press.

I changed my code to use write and appended the \r and everything works like a champ.

Viewing all articles
Browse latest Browse all 1729

Latest Images

Trending Articles



Latest Images