Skip to content

Commit 37f623c

Browse files
committed
*: unify handling of ssh keys
Instead of each platform implementing their own mechanism for supplying SSH keys, use the same method everywhere. Now, instead of using AWS's metadata service, we inject the keys directly via Ignition. Note: The stub Ignition configs contain the SSH keys. Eventually, the keys will need to be moved into MCO, so that they can be rotated.
1 parent 1611a65 commit 37f623c

File tree

25 files changed

+37
-70
lines changed

25 files changed

+37
-70
lines changed

Documentation/design/installconfig.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ type AWS struct {
6868
Master `json:",inline" yaml:"master,omitempty"`
6969
Profile string `json:"tectonic_aws_profile,omitempty" yaml:"profile,omitempty"`
7070
Region string `json:"tectonic_aws_region,omitempty" yaml:"region,omitempty"`
71-
SSHKey string `json:"tectonic_aws_ssh_key,omitempty" yaml:"sshKey,omitempty"`
7271
VPCCIDRBlock string `json:"tectonic_aws_vpc_cidr_block,omitempty" yaml:"vpcCIDRBlock,omitempty"`
7372
Worker `json:",inline" yaml:"worker,omitempty"`
7473
}
@@ -106,7 +105,6 @@ type Worker struct {
106105
```go
107106
type Libvirt struct {
108107
URI string `json:"tectonic_libvirt_uri,omitempty" yaml:"uri"`
109-
SSHKey string `json:"tectonic_libvirt_ssh_key,omitempty" yaml:"sshKey"`
110108
QCOWImagePath string `json:"tectonic_coreos_qcow_path,omitempty" yaml:"imagePath"`
111109
Network `json:",inline" yaml:"network"`
112110
MasterIPs []string `json:"tectonic_libvirt_master_ips,omitempty" yaml:"masterIPs"`

config.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ also be escaped.
267267
EOF
268268
}
269269

270+
variable "tectonic_admin_ssh_key" {
271+
type = "string"
272+
default = ""
273+
274+
description = <<EOF
275+
(optional) The admin user's SSH public key to login to the nodes.
276+
EOF
277+
}
278+
270279
variable "tectonic_ca_cert" {
271280
type = "string"
272281
default = ""

examples/tectonic.aws.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
admin:
22
email: "a@b.c"
33
password: "verysecure"
4+
sshKey: "ssh-ed25519 AAAA..."
45
aws:
56
# (optional) Unique name under which the Amazon S3 bucket will be created. Bucket name must start with a lower case name and is limited to 63 characters.
67
# The Tectonic Installer uses the bucket to store tectonic assets and kubeconfig.
@@ -130,9 +131,6 @@ aws:
130131
# The target AWS region for the cluster.
131132
region: eu-west-1
132133

133-
# Name of an SSH key located within the AWS region. Example: coreos-user.
134-
sshKey:
135-
136134
# Block of IP addresses used by the VPC.
137135
# This should not overlap with any other networks, such as a private datacenter connected via Direct Connect.
138136
vpcCIDRBlock: 10.0.0.0/16

examples/tectonic.libvirt.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
admin:
22
email: a@b.c
33
password: verysecure
4+
sshKey: "ssh-ed25519 AAAA..."
45
# The base DNS domain of the cluster. It must NOT contain a trailing period. Some
56
# DNS providers will automatically add this if necessary.
67
#
@@ -16,7 +17,6 @@ libvirt:
1617
ifName: tt0
1718
dnsServer: 8.8.8.8
1819
ipRange: 192.168.124.0/24
19-
sshKey: "ssh-rsa ..."
2020
imagePath: /path/to/image
2121

2222
ca:

installer/pkg/config-generator/ignition.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ func (c *ConfigGenerator) GenerateIgnConfig(clusterDir string) error {
5757
return err
5858
}
5959

60-
// agentless platforms (e.g. libvirt) need to embed the ssh key
60+
// XXX(crawford): The SSH key should only be added to the bootstrap
61+
// node. After that, MCO should be responsible for
62+
// distributing SSH keys.
6163
c.embedUserBlock(ignCfg)
6264

6365
fileTargetPath := filepath.Join(clusterDir, ignFilesPath[role])
@@ -111,16 +113,14 @@ func (c *ConfigGenerator) appendCertificateAuthority(ignCfg *ignconfigtypes.Conf
111113
}
112114

113115
func (c *ConfigGenerator) embedUserBlock(ignCfg *ignconfigtypes.Config) {
114-
if c.Platform == config.PlatformLibvirt {
115-
userBlock := ignconfigtypes.PasswdUser{
116-
Name: "core",
117-
SSHAuthorizedKeys: []ignconfigtypes.SSHAuthorizedKey{
118-
ignconfigtypes.SSHAuthorizedKey(c.Libvirt.SSHKey),
119-
},
120-
}
121-
122-
ignCfg.Passwd.Users = append(ignCfg.Passwd.Users, userBlock)
116+
userBlock := ignconfigtypes.PasswdUser{
117+
Name: "core",
118+
SSHAuthorizedKeys: []ignconfigtypes.SSHAuthorizedKey{
119+
ignconfigtypes.SSHAuthorizedKey(c.SSHKey),
120+
},
123121
}
122+
123+
ignCfg.Passwd.Users = append(ignCfg.Passwd.Users, userBlock)
124124
}
125125

126126
func (c *ConfigGenerator) getTNCURL(role string) string {

installer/pkg/config/aws/aws.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type AWS struct {
3030
Master `json:",inline" yaml:"master,omitempty"`
3131
Profile string `json:"tectonic_aws_profile,omitempty" yaml:"profile,omitempty"`
3232
Region string `json:"tectonic_aws_region,omitempty" yaml:"region,omitempty"`
33-
SSHKey string `json:"tectonic_aws_ssh_key,omitempty" yaml:"sshKey,omitempty"`
3433
VPCCIDRBlock string `json:"tectonic_aws_vpc_cidr_block,omitempty" yaml:"vpcCIDRBlock,omitempty"`
3534
Worker `json:",inline" yaml:"worker,omitempty"`
3635
}

installer/pkg/config/libvirt/libvirt.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const (
1717
// Libvirt encompasses configuration specific to libvirt.
1818
type Libvirt struct {
1919
URI string `json:"tectonic_libvirt_uri,omitempty" yaml:"uri"`
20-
SSHKey string `json:"tectonic_libvirt_ssh_key,omitempty" yaml:"sshKey"`
2120
QCOWImagePath string `json:"tectonic_coreos_qcow_path,omitempty" yaml:"imagePath"`
2221
Network `json:",inline" yaml:"network"`
2322
MasterIPs []string `json:"tectonic_libvirt_master_ips,omitempty" yaml:"masterIPs"`

installer/pkg/config/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const (
2020
type Admin struct {
2121
Email string `json:"tectonic_admin_email" yaml:"email,omitempty"`
2222
Password string `json:"tectonic_admin_password" yaml:"password,omitempty"`
23+
SSHKey string `json:"tectonic_admin_ssh_key,omitempty" yaml:"sshKey,omitempty"`
2324
}
2425

2526
// CA related config

installer/pkg/config/validate.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ func (c *Cluster) validateLibvirt() []error {
183183
if err := validate.PrefixError("libvirt imagePath is not a valid QCOW image", validate.FileHeader(c.Libvirt.QCOWImagePath, qcowMagic)); err != nil {
184184
errs = append(errs, err)
185185
}
186-
if err := validate.PrefixError("libvirt sshKey", validate.NonEmpty(c.Libvirt.SSHKey)); err != nil {
187-
errs = append(errs, err)
188-
}
189186
if err := validate.PrefixError("libvirt network name", validate.NonEmpty(c.Libvirt.Network.Name)); err != nil {
190187
errs = append(errs, err)
191188
}

installer/pkg/config/validate_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,6 @@ func TestValidateLibvirt(t *testing.T) {
605605
Libvirt: libvirt.Libvirt{
606606
Network: libvirt.Network{},
607607
QCOWImagePath: "",
608-
SSHKey: "",
609608
URI: "",
610609
},
611610
Networking: defaultCluster.Networking,
@@ -622,7 +621,6 @@ func TestValidateLibvirt(t *testing.T) {
622621
IPRange: "10.0.1.0/24",
623622
},
624623
QCOWImagePath: fInvalid.Name(),
625-
SSHKey: "bar",
626624
URI: "baz",
627625
},
628626
Networking: defaultCluster.Networking,
@@ -639,7 +637,6 @@ func TestValidateLibvirt(t *testing.T) {
639637
IPRange: "10.0.1.0/24",
640638
},
641639
QCOWImagePath: fValid.Name(),
642-
SSHKey: "bar",
643640
URI: "baz",
644641
},
645642
Networking: defaultCluster.Networking,
@@ -656,7 +653,6 @@ func TestValidateLibvirt(t *testing.T) {
656653
IPRange: "10.2.1.0/24",
657654
},
658655
QCOWImagePath: fValid.Name(),
659-
SSHKey: "bar",
660656
URI: "baz",
661657
},
662658
Networking: defaultCluster.Networking,
@@ -673,7 +669,6 @@ func TestValidateLibvirt(t *testing.T) {
673669
IPRange: "x",
674670
},
675671
QCOWImagePath: "foo",
676-
SSHKey: "bar",
677672
URI: "baz",
678673
},
679674
Networking: defaultCluster.Networking,
@@ -690,7 +685,6 @@ func TestValidateLibvirt(t *testing.T) {
690685
IPRange: "192.168.0.1/24",
691686
},
692687
QCOWImagePath: "foo",
693-
SSHKey: "bar",
694688
URI: "baz",
695689
},
696690
Networking: defaultCluster.Networking,

0 commit comments

Comments
 (0)