Pass through an explicit PROXY_SSH_USER.

Use user@user instead of user@hostname in case hostname is too long.
This commit is contained in:
CJ Cullen 2015-06-18 10:34:58 -07:00
parent 2330760d34
commit abf1e768dc
2 changed files with 2 additions and 8 deletions

View File

@ -501,7 +501,7 @@ EOF
cat <<EOF >>/etc/salt/minion.d/grains.conf cat <<EOF >>/etc/salt/minion.d/grains.conf
cloud_config: /etc/gce.conf cloud_config: /etc/gce.conf
advertise_address: '${EXTERNAL_IP}' advertise_address: '${EXTERNAL_IP}'
proxy_ssh_user: '${INSTANCE_PREFIX}' proxy_ssh_user: '${PROXY_SSH_USER}'
EOF EOF
fi fi
} }

View File

@ -22,7 +22,6 @@ import (
"io/ioutil" "io/ioutil"
"net" "net"
"net/http" "net/http"
"os"
"path" "path"
"strconv" "strconv"
"strings" "strings"
@ -490,12 +489,7 @@ func (gce *GCECloud) AddSSHKeyToAllInstances(user string, keyData []byte) error
glog.Errorf("Could not get project: %v", err) glog.Errorf("Could not get project: %v", err)
return false, nil return false, nil
} }
hostname, err := os.Hostname() keyString := fmt.Sprintf("%s:%s %s@%s", user, strings.TrimSpace(string(keyData)), user, user)
if err != nil {
glog.Errorf("Could not get hostname: %v", err)
return false, nil
}
keyString := fmt.Sprintf("%s:%s %s@%s", user, strings.TrimSpace(string(keyData)), user, hostname)
found := false found := false
for _, item := range project.CommonInstanceMetadata.Items { for _, item := range project.CommonInstanceMetadata.Items {
if item.Key == "sshKeys" { if item.Key == "sshKeys" {