Documentation
¶
Index ¶
- Constants
- Variables
- type SSHKeyParser
- type SshManager
- type StandardSshManager
- func (sc *StandardSshManager) DeregisterOS() error
- func (sc *StandardSshManager) DisablePasswordSSHLogin() error
- func (sc *StandardSshManager) ExchangeKeys() error
- func (sc *StandardSshManager) ExecuteScript(scriptPath, scriptContent string, postRemove, runWithSudo bool) error
- func (sc *StandardSshManager) IsInit() bool
- func (sc *StandardSshManager) RebootCloudInit() error
- func (sc *StandardSshManager) RegisterOS(regcode, email string) error
- func (sc *StandardSshManager) String() string
- func (sc *StandardSshManager) WriteFileOnRemoteMachine(path, fileContent string, fileMode os.FileMode) error
Constants ¶
const (
SSH_CONNECT_ATTEMPT_DELAY time.Duration = 5 * time.Second
)
Variables ¶
var (
ErrNoneOfConstructorArgsCanBeEmpty = errors.New("none of the arguments can be empty; neither 'hostName', 'userName', 'sshPassword', 'sshKeyPath', 'hostPublicKey'")
)
Functions ¶
This section is empty.
Types ¶
type SSHKeyParser ¶ added in v0.1.8
SSHKeyParser defines the interface for parsing an SSH key from a path.
func NewFileSSHKeyParser ¶ added in v0.1.8
func NewFileSSHKeyParser() SSHKeyParser
NewFileSSHKeyParser creates a new parser that reads from the filesystem.
type SshManager ¶
type SshManager interface {
IsInit() bool
ExchangeKeys() error
ExecuteScript(scriptPath, scriptContent string, postRemove bool, runWithSudo bool) error
WriteFileOnRemoteMachine(path, fileContent string, fileMode os.FileMode) error
DisablePasswordSSHLogin() error
RebootCloudInit() error
RegisterOS(regcode, email string) error
DeregisterOS() error
}
SshManager interface defines the methods for interacting with the SSH Manager.
type StandardSshManager ¶
type StandardSshManager struct {
HostName string
UserName string
SshPassword string
SshKeyPath string
Client ssh.Client
HostPublicKey gossh.PublicKey
// contains filtered or unexported fields
}
StandardSshManager struct holds configuration for SSH Manager interaction.
func NewStandardSshManager ¶
func NewStandardSshManager(hostName, userName, sshPassword, sshKeyPath, hostPublicKey string) (*StandardSshManager, error)
NewStandardSshManager Returns new instance of Standard SSH Manager and error
func (*StandardSshManager) DeregisterOS ¶ added in v0.1.8
func (sc *StandardSshManager) DeregisterOS() error
DeregisterOS - De-registers SLES OS using SUSEConnect
func (*StandardSshManager) DisablePasswordSSHLogin ¶
func (sc *StandardSshManager) DisablePasswordSSHLogin() error
DisablePasswordSSHLogin disables password authentication for SSH on newly created machine
func (*StandardSshManager) ExchangeKeys ¶
func (sc *StandardSshManager) ExchangeKeys() error
func (*StandardSshManager) ExecuteScript ¶
func (sc *StandardSshManager) ExecuteScript(scriptPath, scriptContent string, postRemove, runWithSudo bool) error
ExecuteScript Executes script defined by path and content. Executing procedure consists of few steps:
- if script path is not set (empty), then create a secure temporary subdirectory (e.g. /tmp/fsas-nodedriver) with minimal permissions and prepare the script using a random filename inside that directory (e.g. /tmp/fsas-nodedriver/username-via-ssh-256.sh)
- generate file in above location with given content and grant executable privileges to file
- execute script
- if param 'postRemove' is true then:
- remove script after execution else leave it
- delete secure directory if it is empty.
- if script path is provided, the script is written and executed at that path without directory creation or deletion.
func (*StandardSshManager) IsInit ¶
func (sc *StandardSshManager) IsInit() bool
IsInit Returns true if constructor succeed else false
func (*StandardSshManager) RebootCloudInit ¶
func (sc *StandardSshManager) RebootCloudInit() error
RebootCloudInit() error
func (*StandardSshManager) RegisterOS ¶ added in v0.1.8
func (sc *StandardSshManager) RegisterOS(regcode, email string) error
RegisterOS - Registers SLES OS license using SUSEConnect
func (*StandardSshManager) String ¶
func (sc *StandardSshManager) String() string
func (*StandardSshManager) WriteFileOnRemoteMachine ¶
func (sc *StandardSshManager) WriteFileOnRemoteMachine(path, fileContent string, fileMode os.FileMode) error
WriteFileOnRemoteMachine Writes content to file defined in path