package main
import (
"bytes"
"fmt"
"golang.org/x/crypto/ssh"
_ "os"
_ "strings"
)
func main() {
config := &ssh.ClientConfig{User: "t24test2", Auth: []ssh.AuthMethod{ssh.Password("654321")}}
client, err := ssh.Dial("tcp", "10.3.9.43:22", config)
if err != nil {
panic("Failed to dial: " + err.Error())
}
session, err := client.NewSession()
if err != nil {
panic("Failed to create session: " + err.Error())
}
defer session.Close()
err = session.Setenv("CLASSPATH", "/t24/t24test2/bnk/bnk.run/arcauth/jars/:/t24/t24test2/bnk/bnk.run/arcauth/jars/authentication-t24server.jar:/t24/t24test2/bnk/bnk.run/arcauth/jars/authentication-webcommon.jar:/t24/t24test2/bnk/bnk.run/arcauth/jars/authapi.jar:/t24/t24test2/bnk/bnk.run/arcauth/jars/commons-codec-1.3.jar:/t24/t24test2/bnk/bnk.run/arcauth/jars/SS_4TRESS_PUBLIC_Client.jar:/t24/t24test2/bnk/bnk.run/arcauth/jars/SS_4TRESS_PUBLIC_Client_testing.jar:/t24/t24test2/bnk/bnk.run/arcauth/jars/xml-apis.jar:/t24/t24test2/bnk/bnk.run/arcauth/jars/xerces.jar:/t24/t24test2/bnk/bnk.run/arcauth/jars/jbossall-client.jar:/t24/t24test2/bnk/bnk.run/arcauth/jars/temenos-commons-logging.jar:/t24/t24test2/bnk/bnk.run/arcauth/jars/log4j.properties:/t24/t24test2/bnk/bnk.run/arcauth/jars/log4j-1.2.13.jar")
if err != nil {
panic("Failed to run: " + err.Error())
}
--Using above program, I am unable to setup environment variable to session. System panics and throws the below error message.panic: Failed to run: ssh: setenv failed
goroutine 1 [running]:
main.main()
c:/go/src/workshop/T24_Connect/T24_Connect.go:50 +0x32c
goroutine 5 [IO wait]:
net.(*pollDesc).Wait(0x12204530, 0x72, 0x0, 0x0)
c:/go/src/net/fd_poll_runtime.go:84 +0x42
net.(*ioSrv).ExecIO(0x121fe298, 0x12204498, 0x5a2538, 0x7, 0x5f4ca0, 0x0, 0x0, 0x0)
c:/go/src/net/fd_windows.go:188 +0x265
net.(*netFD).Read(0x12204460, 0x1220c000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
c:/go/src/net/fd_windows.go:470 +0x11a
net.(*conn).Read(0x121fe2a8, 0x1220c000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
c:/go/src/net/net.go:121 +0xba
bufio.(*Reader).fill(0x121e4720)
c:/go/src/bufio/bufio.go:97 +0x15c
bufio.(*Reader).Read(0x121e4720, 0x121ec4f0, 0x5, 0x5, 0x0, 0x0, 0x0)
c:/go/src/bufio/bufio.go:174 +0x1c0
io.ReadAtLeast(0x2b2fe8, 0x121e4720, 0x121ec4f0, 0x5, 0x5, 0x5, 0x0, 0x0, 0x0)
c:/go/src/io/io.go:298 +0xb2
io.ReadFull(0x2b2fe8, 0x121e4720, 0x121ec4f0, 0x5, 0x5, 0x2a0008, 0x0, 0x0)
c:/go/src/io/io.go:316 +0x5c
golang.org/x/crypto/ssh.(*streamPacketCipher).readPacket(0x121ec4e0, 0x8, 0x2b2fe8, 0x121e4720, 0x0, 0x0, 0x0, 0x0, 0x0)
C:/Go/src/src/golang.org/x/crypto/ssh/cipher.go:141 +0xbb
golang.org/x/crypto/ssh.(*connectionState).readPacket(0x12208360, 0x121e4720, 0x0, 0x0, 0x0, 0x0, 0x0)
C:/Go/src/src/golang.org/x/crypto/ssh/transport.go:111 +0xbc
golang.org/x/crypto/ssh.(*transport).readPacket(0x12208360, 0x0, 0x0, 0x0, 0x0, 0x0)
C:/Go/src/src/golang.org/x/crypto/ssh/transport.go:107 +0x5d
golang.org/x/crypto/ssh.(*handshakeTransport).readOnePacket(0x122083f0, 0x0, 0x0, 0x0, 0x0, 0x0)
C:/Go/src/src/golang.org/x/crypto/ssh/handshake.go:153 +0xcc
golang.org/x/crypto/ssh.(*handshakeTransport).readLoop(0x122083f0)
C:/Go/src/src/golang.org/x/crypto/ssh/handshake.go:133 +0x28
created by golang.org/x/crypto/ssh.newClientTransport
C:/Go/src/src/golang.org/x/crypto/ssh/handshake.go:101 +0xfb
goroutine 6 [chan receive]:
golang.org/x/crypto/ssh.(*handshakeTransport).readPacket(0x122083f0, 0x0, 0x0, 0x0, 0x0, 0x0)
C:/Go/src/src/golang.org/x/crypto/ssh/handshake.go:124 +0x7b
golang.org/x/crypto/ssh.(*mux).onePacket(0x121e27c0, 0x0, 0x0)
C:/Go/src/src/golang.org/x/crypto/ssh/mux.go:224 +0x51
golang.org/x/crypto/ssh.(*mux).loop(0x121e27c0)
C:/Go/src/src/golang.org/x/crypto/ssh/mux.go:199 +0x3b
created by golang.org/x/crypto/ssh.newMux
C:/Go/src/src/golang.org/x/crypto/ssh/mux.go:128 +0x173
goroutine 7 [chan receive]:
golang.org/x/crypto/ssh.(*Client).handleGlobalRequests(0x121e4630, 0x121e2740)
C:/Go/src/src/golang.org/x/crypto/ssh/client.go:137 +0x48
created by golang.org/x/crypto/ssh.NewClient
C:/Go/src/src/golang.org/x/crypto/ssh/client.go:54 +0xef
goroutine 8 [chan receive]:
golang.org/x/crypto/ssh.(*Client).handleChannelOpens(0x121e4630, 0x121e2540)
C:/Go/src/src/golang.org/x/crypto/ssh/client.go:146 +0x5a
created by golang.org/x/crypto/ssh.NewClient
C:/Go/src/src/golang.org/x/crypto/ssh/client.go:55 +0x10e
goroutine 9 [semacquire]:
sync.(*Cond).Wait(0x121e7e00)
c:/go/src/sync/cond.go:62 +0x88
golang.org/x/crypto/ssh.(*mux).Wait(0x121e27c0, 0x0, 0x0)
C:/Go/src/src/golang.org/x/crypto/ssh/mux.go:110 +0x9a
golang.org/x/crypto/ssh.func·003()
C:/Go/src/src/golang.org/x/crypto/ssh/client.go:57 +0x3f
created by golang.org/x/crypto/ssh.NewClient
C:/Go/src/src/golang.org/x/crypto/ssh/client.go:59 +0x150
goroutine 10 [chan receive]:
golang.org/x/crypto/ssh.(*forwardList).handleChannels(0x121e4638, 0x121e2880)
C:/Go/src/src/golang.org/x/crypto/ssh/tcpip.go:178 +0x5a
created by golang.org/x/crypto/ssh.NewClient
C:/Go/src/src/golang.org/x/crypto/ssh/client.go:60 +0x194
goroutine 11 [chan receive]:
golang.org/x/crypto/ssh.(*Session).wait(0x121ea3c0, 0x121e28c0, 0x0, 0x0)
C:/Go/src/src/golang.org/x/crypto/ssh/session.go:400 +0x7b
golang.org/x/crypto/ssh.func·011()
C:/Go/src/src/golang.org/x/crypto/ssh/session.go:558 +0x36
created by golang.org/x/crypto/ssh.newSession
C:/Go/src/src/golang.org/x/crypto/ssh/session.go:559 +0x158