Skip to content

Commit

Permalink
Modify arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
yukirii committed May 28, 2017
1 parent e647e60 commit d5595e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func (ki KeyboardInteractive) Challenge(user, instruction string, questions []st
return answers, nil
}

func NewSSHConnection(host, user, password string) (*SSHConn, error) {
session, err := newSSHSession(host, user, password)
func NewSSHConnection(addr, user, password string) (*SSHConn, error) {
session, err := newSSHSession(addr, user, password)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -65,9 +65,7 @@ func NewSSHConnection(host, user, password string) (*SSHConn, error) {
}, nil
}

func newSSHSession(host, user, password string) (*ssh.Session, error) {
port := "22"

func newSSHSession(addr, user, password string) (*ssh.Session, error) {
answers := KeyboardInteractive(map[string]string{
"Password: ": password,
})
Expand All @@ -83,7 +81,7 @@ func newSSHSession(host, user, password string) (*ssh.Session, error) {
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}

conn, err := ssh.Dial("tcp", host+":"+port, config)
conn, err := ssh.Dial("tcp", addr, config)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions tmsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ type SSHConn struct {
stderr io.Reader
}

func NewSession(host, user, password string) (*BigIP, error) {
sshconn, err := NewSSHConnection(host, user, password)
func NewSession(host, port, user, password string) (*BigIP, error) {
sshconn, err := NewSSHConnection(host+":"+port, user, password)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit d5595e0

Please sign in to comment.