Skip to content

Commit 73adedf

Browse files
iso: added authorized keys into /root
1 parent de81223 commit 73adedf

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

deploy/iso/minikube-iso/package/automount/minikube-automount

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ if [ -n "$BOOT2DOCKER_DATA" ]; then
155155
chown -R docker:docker /home/docker/.ssh
156156
rm -f '/home/docker/boot2docker, please format-me'
157157

158+
tar xf /var/lib/boot2docker/userdata.tar -C /root/
159+
chown -R root:root /root/.ssh
160+
rm -f '/root/boot2docker, please format-me'
161+
158162
mkdir -p /mnt/$PARTNAME/var/lib/minikube
159163
mkdir /var/lib/minikube
160164
mount --bind /mnt/$PARTNAME/var/lib/minikube /var/lib/minikube

deploy/kicbase/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ USER root
284284
# kind base-image entry-point expects a "kind" folder for product_name,product_uuid
285285
# https://github.com/kubernetes-sigs/kind/blob/master/images/base/files/usr/local/bin/entrypoint
286286
RUN mkdir -p /kind
287+
RUN mkdir -p /root/.ssh
287288
# Deleting leftovers
288289
RUN rm -rf \
289290
/usr/share/doc/* \

pkg/drivers/kic/kic.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,30 @@ func (d *Driver) prepareSSH() error {
227227
}
228228

229229
cmder := command.NewKICRunner(d.NodeConfig.MachineName, d.NodeConfig.OCIBinary)
230-
f, err := assets.NewFileAsset(d.GetSSHKeyPath()+".pub", "/home/docker/.ssh/", "authorized_keys", "0644")
230+
f1, err := assets.NewFileAsset(d.GetSSHKeyPath()+".pub", "/home/docker/.ssh/", "authorized_keys", "0644")
231231
if err != nil {
232232
return fmt.Errorf("create pubkey assetfile : %w", err)
233233
}
234+
235+
f2, err := assets.NewFileAsset(d.GetSSHKeyPath()+".pub", "/root/.ssh/", "authorized_keys", "0644")
236+
if err != nil {
237+
return fmt.Errorf("create pubkey assetfile : %w", err)
238+
}
239+
234240
defer func() {
235-
if err := f.Close(); err != nil {
236-
klog.Warningf("error closing the file %s: %v", f.GetSourcePath(), err)
241+
if err := f1.Close(); err != nil {
242+
klog.Warningf("error closing the file %s: %v", f1.GetSourcePath(), err)
243+
}
244+
if err := f2.Close(); err != nil {
245+
klog.Warningf("error closing the file %s: %v", f2.GetSourcePath(), err)
237246
}
238247
}()
239248

240-
if err := cmder.Copy(f); err != nil {
241-
return fmt.Errorf("copying pub key: %w", err)
249+
if err := cmder.Copy(f1); err != nil {
250+
return fmt.Errorf("copying pub key in /home/docker/.ssh/: %w", err)
251+
}
252+
if err := cmder.Copy(f2); err != nil {
253+
return fmt.Errorf("copying pub key in /root/.ssh/: %w", err)
242254
}
243255

244256
// Double-check that the container has not crashed so that we may give a better error message
@@ -256,6 +268,10 @@ func (d *Driver) prepareSSH() error {
256268
return fmt.Errorf("apply authorized_keys file ownership, output %s: %w", rr.Output(), err)
257269
}
258270

271+
if rr, err := cmder.RunCmd(exec.Command("chown", "root:root", "/root/.ssh/authorized_keys")); err != nil {
272+
return fmt.Errorf("apply authorized_keys file ownership, output %s: %w", rr.Output(), err)
273+
}
274+
259275
if runtime.GOOS == "windows" {
260276
path, _ := exec.LookPath("powershell")
261277
ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second)

0 commit comments

Comments
 (0)