ginuerzh/gost · error
session is dead
Error message
session is dead
What it means
errSessionDead is a sentinel error returned by the SSH forward transporters when the cached sshSession for the target address is found in the session map but its underlying SSH connection is already closed; the dead entry is removed from the map before returning. It means the pooled SSH tunnel went away and the requested forward cannot be delivered over it.
Source
Thrown at ssh.go:30
"strings"
"sync"
"time"
"github.com/go-log/log"
"golang.org/x/crypto/ssh"
)
// Applicable SSH Request types for Port Forwarding - RFC 4254 7.X
const (
DirectForwardRequest = "direct-tcpip" // RFC 4254 7.2
RemoteForwardRequest = "tcpip-forward" // RFC 4254 7.1
ForwardedTCPReturnRequest = "forwarded-tcpip" // RFC 4254 7.2
CancelRemoteForwardRequest = "cancel-tcpip-forward" // RFC 4254 7.1
GostSSHTunnelRequest = "gost-tunnel" // extended request type for ssh tunnel
)
var errSessionDead = errors.New("session is dead")
// ParseSSHKeyFile parses ssh key file.
func ParseSSHKeyFile(fp string) (ssh.Signer, error) {
key, err := os.ReadFile(fp)
if err != nil {
return nil, err
}
return ssh.ParsePrivateKey(key)
}
// ParseSSHAuthorizedKeysFile parses ssh Authorized Keys file.
func ParseSSHAuthorizedKeysFile(fp string) (map[string]bool, error) {
authorizedKeysBytes, err := os.ReadFile(fp)
if err != nil {
return nil, err
}
authorizedKeysMap := make(map[string]bool)
for len(authorizedKeysBytes) > 0 {View on GitHub (pinned to a33fdbf4c9)
Solutions
- Treat the error as a signal to re-establish the SSH session and retry the forward request
- Check network connectivity and SSH server availability that caused the session to drop
- Enable SSH keep-alives so dead sessions are detected and evicted earlier
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at ssh.go:30 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ginuerzh/gost@a33fdbf4c9 (2026-09-02).
Data as JSON: /api/errors/bae911c7eb95ac17.
Report an issue: GitHub.