Skip to content

Commit

Permalink
refactor: set defaul user to root if user not given
Browse files Browse the repository at this point in the history
  • Loading branch information
vimiix committed Apr 17, 2024
1 parent 70aef5d commit 2613c9e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ssx/entry/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ const (
SourceSSXStore = "ssx_store"
)

const defaultIdentityFile = "~/.ssh/id_rsa"
const (
defaultIdentityFile = "~/.ssh/id_rsa"
defaultUser = "root"
)

// Entry represent a target server
type Entry struct {
Expand Down Expand Up @@ -147,11 +150,7 @@ func (e *Entry) sshHostKeyCallback() (ssh.HostKeyCallback, error) {

func (e *Entry) Tidy() error {
if len(e.User) <= 0 {
curUsername, err := utils.CurrentUserName()
if err != nil {
return err
}
e.User = curUsername
e.User = defaultUser
}
if len(e.Port) <= 0 {
e.Port = "22"
Expand Down

0 comments on commit 2613c9e

Please sign in to comment.