Documentation
¶
Index ¶
- Constants
- Variables
- type SshManager
- type StandardSshManager
- func (sc *StandardSshManager) DisablePasswordSSHLogin() error
- func (sc *StandardSshManager) ExchangeKeys(sshKeyPath string) 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) String() string
- func (sc *StandardSshManager) WriteFileOnRemoteMachine(path, fileContent string, fileMode os.FileMode) error
Constants ¶
View Source
const (
SSH_CONNECT_ATTEMPT_DELAY time.Duration = 5 * time.Second
)
Variables ¶
View Source
var (
ErrNoneOfConstructorArgsCanBeEmpty = errors.New("none of the arguments can be empty; neither 'hostName', 'userName', 'sshPassword', 'hostPublicKey'")
)
Functions ¶
This section is empty.
Types ¶
type SshManager ¶
type SshManager interface { IsInit() bool ExchangeKeys(sshKeyPath string) error ExecuteScript(scriptPath, scriptContent string, postRemove bool, runWithSudo bool) error WriteFileOnRemoteMachine(path, fileContent string, fileMode os.FileMode) error DisablePasswordSSHLogin() error RebootCloudInit() 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 }
StandardSshManager struct holds configuration for SSH Manager interaction.
func NewStandardSshManager ¶
func NewStandardSshManager(hostName, userName, sshPassword, hostPublicKey string) (*StandardSshManager, error)
NewStandardSshManager Returns new instance of Standard SSH Manager and error
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(sshKeyPath string) 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) 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
Click to show internal directories.
Click to hide internal directories.