Skip to content

Commit

Permalink
fix(ssh): Set default host key dir to ~/.ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Apr 19, 2024
1 parent 5d7beb2 commit 2095cbb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/server/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"errors"
"fmt"
"os"
"strings"
"time"

tea "github.com/charmbracelet/bubbletea"
Expand Down Expand Up @@ -37,6 +39,10 @@ func NewSSH(flags *flag.FlagSet) SSHServer {
panic(err)
}

if len(ssh.HostKeyPath) == 0 && len(ssh.HostKeyPEM) == 0 {
ssh.HostKeyPath = []string{"$HOME/.ssh/ascii_movie_ed25519", "$HOME/.ssh/ascii_movie_rsa"}
}

return ssh
}

Expand All @@ -58,6 +64,13 @@ func (s *SSHServer) Listen(ctx context.Context, m *movie.Movie) error {
}

for _, path := range s.HostKeyPath {
if strings.Contains(path, "$HOME") {
home, err := os.UserHomeDir()
if err != nil {
return err
}
path = strings.ReplaceAll(path, "$HOME", home)
}
sshOptions = append(sshOptions, wish.WithHostKeyPath(path))
}

Expand Down

0 comments on commit 2095cbb

Please sign in to comment.