mirror of
https://github.com/rancher/os.git
synced 2025-07-13 06:34:04 +00:00
Keep the sshd config file when using the previous console version
This commit is contained in:
parent
19cf9b28bc
commit
4546fac3c2
@ -31,6 +31,8 @@ const (
|
|||||||
rancherHome = "/home/rancher"
|
rancherHome = "/home/rancher"
|
||||||
startScript = "/opt/rancher/bin/start.sh"
|
startScript = "/opt/rancher/bin/start.sh"
|
||||||
runLockDir = "/run/lock"
|
runLockDir = "/run/lock"
|
||||||
|
sshdFile = "/etc/ssh/sshd_config"
|
||||||
|
sshdTplFile = "/etc/ssh/sshd_config.tpl"
|
||||||
)
|
)
|
||||||
|
|
||||||
type symlink struct {
|
type symlink struct {
|
||||||
@ -322,12 +324,14 @@ func writeRespawn(user string, sshd, recovery bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func modifySshdConfig(cfg *config.CloudConfig) error {
|
func modifySshdConfig(cfg *config.CloudConfig) error {
|
||||||
os.Remove("/etc/ssh/sshd_config")
|
_, err := os.Stat(sshdTplFile)
|
||||||
sshdTpl, err := template.ParseFiles("/etc/ssh/sshd_config.tpl")
|
if err == nil {
|
||||||
|
os.Remove(sshdFile)
|
||||||
|
sshdTpl, err := template.ParseFiles(sshdTplFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
f, err := os.OpenFile("/etc/ssh/sshd_config", os.O_WRONLY|os.O_CREATE, 0644)
|
f, err := os.OpenFile(sshdFile, os.O_WRONLY|os.O_CREATE, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -342,6 +346,11 @@ func modifySshdConfig(cfg *config.CloudConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return sshdTpl.Execute(f, config)
|
return sshdTpl.Execute(f, config)
|
||||||
|
} else if os.IsNotExist(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupSSH(cfg *config.CloudConfig) error {
|
func setupSSH(cfg *config.CloudConfig) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user