mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 17:49:10 +00:00
Merge pull request #3431 from zimme/metadata-fix-provider-hetzner
Fix the Hetzner provider in the metadata package
This commit is contained in:
commit
725dc47a37
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -128,17 +127,15 @@ func (p *ProviderHetzner) handleSSH() error {
|
|||||||
return fmt.Errorf("Failed to create %s: %s", SSH, err)
|
return fmt.Errorf("Failed to create %s: %s", SSH, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileHandle, _ := os.OpenFile(path.Join(ConfigPath, SSH, "authorized_keys"), os.O_CREATE|os.O_APPEND, 0600)
|
fileHandle, _ := os.OpenFile(path.Join(ConfigPath, SSH, "authorized_keys"), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
|
||||||
writer := bufio.NewWriter(fileHandle)
|
|
||||||
defer fileHandle.Close()
|
defer fileHandle.Close()
|
||||||
|
|
||||||
for _, sshKey := range sshKeys {
|
for _, sshKey := range sshKeys {
|
||||||
_, err = fmt.Fprintln(writer, sshKey)
|
_, err = fileHandle.WriteString(sshKey + "\n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to write ssh keys: %s", err)
|
return fmt.Errorf("Failed to write ssh keys: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.Flush()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user