Skip to content

x/crypto/ssh: Session.Run() returns error EOF #16194

@Farioko

Description

@Farioko

Hi,

I'm trying to run commands on a router through SSH. The program works fine if I run it against an OpenSSH server, but against the router with its own proprietary implementation of ssh, Session.Run() returns the error EOF. I'm running Go 1.6.2 and tried executing this program on Linux amd64, Windows amd64, Windows i386. Is this a bug and is there a work around?

package main

import(
        "log"
        "bytes"
        "golang.org/x/crypto/ssh"
)

func main() {
        config := &ssh.ClientConfig{
                User: "admin",
                Auth: []ssh.AuthMethod{ssh.Password("admin")},
                Config: ssh.Config{
                        Ciphers: []string{"aes128-cbc"},
                },
        }

        client, err := ssh.Dial("tcp", "192.168.1.1:22", config)
        if err != nil {
                log.Fatalln("Unable to connect: " + err.Error())
        }

        defer client.Close()

        session, err := client.NewSession()
        if err != nil {
                log.Fatalln("Unable to open session: " + err.Error())
        }

        var b bytes.Buffer
        session.Stdout = &b

        err = session.Run("show Device")
        if err != nil {
                log.Fatalln("Unable to run command: " + err.Error())
        }

        log.Println(b.String())
}

The program returns the following:

Unable to run command: EOF.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions