none
How to open SSH Session and type command behind the seen ? RRS feed

  • Question

  • Hello , 

    I have one question , How to open SSH Session and type command behind the seen ? 

    i have a router that has SSH enabled , want to create a program once the user click on login , it will automatically open ssh connection with the router IP , enter credentials , type few commands then close the session 

    all of that behin the seen of the user and without interrupting the computer using

    is that doable ? 

    Tuesday, September 3, 2019 11:21 AM

All replies

  • What is the make & model # of the router and what commands do you want to send to it ?
    Wednesday, September 4, 2019 1:10 AM
  • it's juniper router MX480 , router ip 192.168.1.1

    SSH to 192.168.1.1

    Credentials are admin , admin

    command is 

    set interfaces ge-0/0/1 disable

    this is a simple example

    Wednesday, September 4, 2019 8:51 AM
  • Something along these lines:
                'https://github.com/sshnet/SSH.NET
                Dim connInfo As New Renci.SshNet.PasswordConnectionInfo("192.168.1.1", "admin", "admin")
                Dim cmd As Renci.SshNet.SshCommand
                Using sshClient As New Renci.SshNet.SshClient(connInfo)
                    sshClient.Connect()
                    cmd = sshClient.RunCommand("set interfaces ge-0/0/1 disable")
                    sshClient.Disconnect()
                End Using
    
    Renci SSH.NET must be added as a reference to the project. The above is from an older project so the syntax and possibly the requirements are different now.
    Friday, September 6, 2019 2:02 PM
  • it's not working with me 

    i don't know where is exactly the issue

    Sunday, September 15, 2019 11:53 AM
  • it's not working with me 

    i don't know where is exactly the issue

    Please be specific in regards to "It's not working for me" as this may mean many things and we don't care to guess.

    "i don't know where is exactly the issue", we don't either with the limited information provided.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Sunday, September 15, 2019 12:00 PM
    Moderator
  • I can't find Renci SSH.NET in the references list

    i'm using VB2010

    Tuesday, September 24, 2019 6:45 AM
  • Hi,

    Please provide your code so we can assist you, without code it is purely guess work. When providing the code please indicate the methods and events also.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 8, 2019 5:22 AM
    Moderator