You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What does 'go version' print?
** go version go1.3 linux/amd64
What steps reproduce the problem?
** Running the test case attached.
What happened?
** Trying to run a command through an ssh session create socket files (I think...) that
are not properly closed. When running such a program a large multiple number of times,
there is a big chance to reach the number of files opened imposed by the system (ulimit
-n). The evidence of such a creation can be accessed in /proc/${PID_OF_PROGRAM}/fd where
the number of file descriptors increase without stopping.
Reproducing all steps without calling session.Run(command) does not show this behaviour.
Since the documentation to use the ssh package is not very clear, I'm maybe missing
something...
What should have happened instead?
** A non increasing number of opened files when running multiple command with multiple
sessions.
** See the attached file for a test case (should work as it with go test...or not)
Thank you for any suggestion!
rsc
changed the title
ssh: running command in session create not closed files
x/crypto/ssh: running command in session create not closed files
Apr 14, 2015
func main() {
// Run a command for test
log.Println("pid ", os.Getpid())
for i := 0; i < 100; i++ {
log.Println("attempt ", i)
s := os.Getenv("SSH_AUTH_SOCK")
c, err := net.Dial("unix", s)
if err != nil { log.Fatal(err)}
a := agent.NewClient(c)
// Construct the configuration with password authentication
Config := &ssh.ClientConfig{
User: "hanwen",
Auth: []ssh.AuthMethod{ ssh.PublicKeysCallback(a.Signers) },
}
Client, err := ssh.Dial(
"tcp",
"localhost:22",
Config,
)
if err != nil {
println("Can't connect to host!\n",
"Reason is: ", err.Error())
}
// create session
session, err := Client.NewSession()
if err != nil {
println(
"Failed to create the session!\n",
"Reason is :", err.Error(),
)
}
// run a command
err = session.Run("whoami")
if err != nil {
println("Failed to execute a command!\n",
"Reason is: ", err.Error(),
)
}
//close session
session.Close()
Client.Close()
}
by acanthyostega:
Attachments:
The text was updated successfully, but these errors were encountered: