Skip to content
Merged
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
20 changes: 17 additions & 3 deletions upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
"time"

Expand All @@ -29,8 +30,10 @@ var Busy = false

// Auth contains username and password used for a network upload
type Auth struct {
Username string `json:"username"`
Password string `json:"password"`
Username string `json:"username"`
Password string `json:"password"`
PrivateKey string `json:"private_key"`
Port int `json:"port"`
}

// Extra contains some options used during the upload
Expand Down Expand Up @@ -375,8 +378,19 @@ func form(port, board, file string, auth Auth, l Logger) error {
func ssh(port string, files []string, commandline string, auth Auth, l Logger, SSH bool) error {
debug(l, "Connect via ssh ", files, commandline)

if auth.Port == 0 {
auth.Port = 22
}

// Connect via ssh
client, err := simplessh.ConnectWithPassword(port+":22", auth.Username, auth.Password)
var client *simplessh.Client
var err error
if auth.PrivateKey != "" {
client, err = simplessh.ConnectWithKey(port+":"+strconv.Itoa(auth.Port), auth.Username, auth.PrivateKey)
} else {
client, err = simplessh.ConnectWithPassword(port+":"+strconv.Itoa(auth.Port), auth.Username, auth.Password)
}

if err != nil {
return errors.Wrapf(err, "Connect via ssh")
}
Expand Down