Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ssh tunnel for insecure option #329

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions cmd/ssh-tunnel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,22 @@
hostkeyFile := flag.String("hostkeyfile", "", "file with public key for SSH host check")
flag.Parse()

pubkey, err := os.ReadFile(*hostkeyFile)
if err != nil {
log.Fatalf("unable to read private key: %v", err)
}
hostkey, err := ssh.ParsePublicKey(pubkey)
if err != nil {
log.Fatalf("unable to parse private key: %v", err)
}
var hostKeyCallback ssh.HostKeyCallback

hostKeyCallback := trustedHostKeyCallback(hostkey)
// Implement a HostKeyCallback to verify the server's host key
if *hostkeyFile != "" {
pubkey, err := os.ReadFile(*hostkeyFile)
if err != nil {
log.Fatalf("unable to hostkeyFile: %v", err)
}
hostkey, err := ssh.ParsePublicKey(pubkey)
if err != nil {
log.Fatalf("unable to parse private key: %v", err)
}

hostKeyCallback = trustedHostKeyCallback(hostkey)
} else {
hostKeyCallback = ssh.InsecureIgnoreHostKey()

Check failure on line 82 in cmd/ssh-tunnel/main.go

View workflow job for this annotation

GitHub Actions / lint

G106: Use of ssh InsecureIgnoreHostKey should be audited (gosec)
}

key, err := os.ReadFile(*keyFile)
if err != nil {
Expand Down
Loading