Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

237 sshpublickey and sshpublickeypath should be compatible #247

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion doc/manpages/ocne-config.yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,19 @@ clusterDefinitionInline: |
# The rescue shell is only available when Oracle Cloud Native Environment fails to start
# properly on that instance. The password hash must be generated
# using SHA512.
password: <some-password-hash>
password:

# Optional public ssh key for the "ocne" user.
# The public key is added to the authorized_keys file for the "ocne" user.
# If both the sshPublicKey and sshPublicKeyPath fields are specified
# then the sshPublicKeyPath field is ignored.
sshPublicKey:

# Optional path to a public ssh key for the "ocne" user on the local host.
# The public key is added to the authorized_keys file for the "ocne" user.
# If both the sshPublicKey and sshPublicKeyPath fields are specified
# then the sshPublicKeyPath field is ignored.
sshPublicKeyPath:

# A list of catalogs to deploy to the target cluster after it has been
# instantiated.
Expand Down
14 changes: 13 additions & 1 deletion doc/manpages/ocne-defaults.yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ clusterDefinitionInline: |
somekey: someval
someotherkey: someotherval

# Optional public ssh key for the "ocne" user.
# The public key is added to the authorized_keys file for the "ocne" user.
# If both the sshPublicKey and sshPublicKeyPath fields are specified
# then the sshPublicKeyPath field is ignored.
sshPublicKey:

# Optional path to a public ssh key for the "ocne" user on the local host.
# The public key is added to the authorized_keys file for the "ocne" user.
# If both the sshPublicKey and sshPublicKeyPath fields are specified
# then the sshPublicKeyPath field is ignored.
sshPublicKeyPath:

# This field specifies the password set for the "ocne" user.
# This configuration is applied through ignition. Certain providers
# require an ignition file to be passed in with the desired password
Expand All @@ -91,7 +103,7 @@ clusterDefinitionInline: |
# The rescue shell is only available when Oracle Cloud Native Environment fails to start
# properly on that instance. The password hash must be generated
# using SHA512.
password: <some-password-hash>
password:

# Provider-specific configuration options.
providers:
Expand Down
13 changes: 6 additions & 7 deletions pkg/cluster/ignition/library.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2024, Oracle and/or its affiliates.
// Copyright (c) 2024, 2025, Oracle and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

package ignition
Expand All @@ -15,6 +15,7 @@ import (
"github.com/oracle-cne/ocne/pkg/config/types"
"github.com/oracle-cne/ocne/pkg/image"
"github.com/oracle-cne/ocne/pkg/util"
"github.com/oracle-cne/ocne/pkg/util/logutils"
)

const (
Expand Down Expand Up @@ -538,12 +539,10 @@ func Proxy(inProxy *types.Proxy, noProxies ...string) (*igntypes.Config, error)
func OcneUser(sshKey string, sshKeyPath string, password string) (*igntypes.Config, error) {
ret := NewIgnition()

// Only allow either ssh key or path to be specified
if sshKey != "" && sshKeyPath != "" {
return nil, fmt.Errorf("Cannot specify both an ssh key and a path to an ssh key file")
zabdulre marked this conversation as resolved.
Show resolved Hide resolved
}

if sshKeyPath != "" {
if sshKey != "" {
logutils.Debug("User specified sshKey in configuration, ignoring sshKeyPath")
} else if sshKeyPath != "" {
logutils.Debug("User specified sshKeyPath in configuration, reading key file")
keyBytes, err := os.ReadFile(sshKeyPath)
if err != nil {
return nil, err
Expand Down