Skip to content

problem with ssh.Run #10

Description

@Arnold1

hi,

1.) how can you set the server destination directory to /home when running err := ssh.Scp("/home/core/zipkin.rb") ... i login with root and the file gets placed into /root ...

2.)
i tried to run the following test, do you now what goes wrong?

my app on the server expects 1 parameter. it works fine when i run response, err := ssh.Run("cd /home; ./app 1")

but why does it fails with no parameter passed? ...see below

package main

import (
    "fmt"
    "github.com/hypersleep/easyssh"
)

func main() {
    // Create MakeConfig instance with remote username, server address and path to private key.
    ssh := &easyssh.MakeConfig{
        User: "xxx",
        Server: "xxx",
        // Optional key or Password without either we try to contact your agent SOCKET
        //Key: "/.ssh/id_rsa",
        Password: "xxx",        
        Port: "22",
    }

    // Call Run method with command you want to run on remote server.
    response, err := ssh.Run("cd /home; ./app")
    // Handle errors
    if err != nil {
        panic("Can't run remote command: " + err.Error())
    } else {
        fmt.Println(response)
    }
}

./main
panic: Can't run remote command: Process exited with: 1. Reason was: ()

goroutine 1 [running]:
runtime.panic(0x561dc0, 0xc21000ae70)
/usr/lib/go/src/pkg/runtime/panic.c:266 +0xb6
main.main()
/home/redpitaya/golang_test/main.go:53 +0x15b

goroutine 3 [syscall]:
runtime.goexit()
/usr/lib/go/src/pkg/runtime/proc.c:1394

goroutine 4 [IO wait]:
net.runtime_pollWait(0x7fa608d4d238, 0x72, 0x0)
/usr/lib/go/src/pkg/runtime/netpoll.goc:116 +0x6a
net.(_pollDesc).Wait(0xc210058290, 0x72, 0x7fa608d4c0e8, 0xb)
/usr/lib/go/src/pkg/net/fd_poll_runtime.go:81 +0x34
net.(_pollDesc).WaitRead(0xc210058290, 0xb, 0x7fa608d4c0e8)
/usr/lib/go/src/pkg/net/fd_poll_runtime.go:86 +0x30
net.(_netFD).Read(0xc210058230, 0xc210070000, 0x1000, 0x1000, 0x0, ...)
/usr/lib/go/src/pkg/net/fd_unix.go:204 +0x2a0
net.(_conn).Read(0xc2100000b0, 0xc210070000, 0x1000, 0x1000, 0xbcc449b49674fe54, ...)
/usr/lib/go/src/pkg/net/net.go:122 +0xc5
bufio.(_Reader).fill(0xc2100380c0)
/usr/lib/go/src/pkg/bufio/bufio.go:91 +0x110
bufio.(_Reader).Read(0xc2100380c0, 0xc21005ae20, 0x5, 0x5, 0x5, ...)
/usr/lib/go/src/pkg/bufio/bufio.go:159 +0x1a4
io.ReadAtLeast(0x7fa608d4d7c8, 0xc2100380c0, 0xc21005ae20, 0x5, 0x5, ...)
/usr/lib/go/src/pkg/io/io.go:288 +0xf6
io.ReadFull(0x7fa608d4d7c8, 0xc2100380c0, 0xc21005ae20, 0x5, 0x5, ...)
/usr/lib/go/src/pkg/io/io.go:306 +0x71
golang.org/x/crypto/ssh.(_streamPacketCipher).readPacket(0xc21005ae00, 0xc20000000d, 0x7fa608d4d7c8, 0xc2100380c0, 0x5, ...)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/cipher.go:142 +0xa4
golang.org/x/crypto/ssh.(_connectionState).readPacket(0xc2100597e0, 0xc2100380c0, 0x4044d9, 0xc210072050, 0xc210072148, ...)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/transport.go:111 +0x74
golang.org/x/crypto/ssh.(_transport).readPacket(0xc2100597e0, 0xc2100002b8, 0x5, 0x0, 0x0, ...)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/transport.go:107 +0x3a
golang.org/x/crypto/ssh.(_handshakeTransport).readOnePacket(0xc21005c0f0, 0xc210072000, 0xc2100002b8, 0x5, 0x5, ...)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/handshake.go:153 +0x97
golang.org/x/crypto/ssh.(*handshakeTransport).readLoop(0xc21005c0f0)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/handshake.go:133 +0x27
created by golang.org/x/crypto/ssh.newClientTransport
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/handshake.go:101 +0x100

goroutine 5 [chan receive]:
golang.org/x/crypto/ssh.(_handshakeTransport).readPacket(0xc21005c0f0, 0xc2100002b8, 0x5, 0x5, 0x0, ...)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/handshake.go:124 +0x34
golang.org/x/crypto/ssh.(_mux).onePacket(0xc2100581c0, 0x0, 0x0)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/mux.go:224 +0x3a
golang.org/x/crypto/ssh.(*mux).loop(0xc2100581c0)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/mux.go:199 +0x3e
created by golang.org/x/crypto/ssh.newMux
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/mux.go:128 +0xf3

goroutine 6 [chan receive]:
golang.org/x/crypto/ssh.(*Client).handleGlobalRequests(0xc210085b80, 0xc21004d700)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/client.go:137 +0x3a
created by golang.org/x/crypto/ssh.NewClient
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/client.go:54 +0xbb

goroutine 7 [chan receive]:
golang.org/x/crypto/ssh.(*Client).handleChannelOpens(0xc210085b80, 0xc210088000)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/client.go:146 +0x45
created by golang.org/x/crypto/ssh.NewClient
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/client.go:55 +0xdf

goroutine 8 [semacquire]:
sync.runtime_Syncsemacquire(0xc210085b50)
/usr/lib/go/src/pkg/runtime/sema.goc:257 +0xca
sync.(_Cond).Wait(0xc210085b40)
/usr/lib/go/src/pkg/sync/cond.go:62 +0x89
golang.org/x/crypto/ssh.(_mux).Wait(0xc2100581c0, 0x0, 0x0)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/mux.go:110 +0x8d
golang.org/x/crypto/ssh.func·004()
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/client.go:57 +0x37
created by golang.org/x/crypto/ssh.NewClient
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/client.go:59 +0x10c

goroutine 9 [chan receive]:
golang.org/x/crypto/ssh.(*forwardList).handleChannels(0xc210085b90, 0xc210088160)
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/tcpip.go:178 +0x4b
created by golang.org/x/crypto/ssh.NewClient
/home/redpitaya/golang/src/golang.org/x/crypto/ssh/client.go:60 +0x15e

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions