Dagger
Search

ssh

SSH in with a password or IdentityFile to execute commands on the remote server.
Example (UseKey)
no available example in current language
func (e *Examples) SSH_UseKey(destination string, key *dagger.Secret) *dagger.Container {
	return dag.SSH().
		Config(destination).
		WithIdentityFile(key).
		Command(`echo "Hello, world!"`)
}
no available example in current language
no available example in current language
Example (UsePassword)
no available example in current language
func (e *Examples) SSH_UsePassword(destination string, password string) *dagger.Container {
	return dag.SSH().
		Config(destination).
		WithPassword(dag.SetSecret("password", password)).
		Command(`echo "Hello, world!"`)
}
no available example in current language
no available example in current language
Example (UseKeyWithOption)
no available example in current language
func (e *Examples) SSH_UseKeyWithOption(sshd *dagger.Service, key *dagger.Secret) *dagger.Container {
	return dag.SSH().
		Config("admin@sshd", dagger.SSHConfigOpts{
			Port:    8022,
			BaseCtr: dag.SSH().BaseContainer().WithServiceBinding("sshd", sshd),
		}).
		WithIdentityFile(key).
		Command(`echo "Hello, world!"`)
}
no available example in current language
no available example in current language
Example (UsePasswordWithOption)
no available example in current language
func (e *Examples) SSH_UsePasswordWithOption(sshd *dagger.Service, password string) *dagger.Container {
	return dag.SSH().
		Config("admin@sshd", dagger.SSHConfigOpts{
			Port:    8022,
			BaseCtr: dag.SSH().BaseContainer().WithServiceBinding("sshd", sshd),
		}).
		WithPassword(dag.SetSecret("password", password)).
		Command(`echo "Hello, world!"`)
}
no available example in current language
no available example in current language

Installation

dagger install github.com/seungyeop-lee/daggerverse/ssh@v0.2.5

Entrypoint

Return Type
Ssh
Example
dagger -m github.com/seungyeop-lee/daggerverse/ssh@05a5d11c78e35558e860540308c7dc73b370c795 call \
func (m *myModule) example() *Ssh  {
	return dag.
			Ssh()
}
@function
def example() -> dag.Ssh:
	return (
		dag.ssh()
	)
@func()
example(): Ssh {
	return dag
		.ssh()
}

Types

Ssh 🔗

SSH dagger module

baseContainer() 🔗

Get the base container for the SSH module. Used when you need to inject a Service into a BaseContainer and run it.

Example:

dag.SSH().Config("admin@sshd", SSHConfigOpts{
	Port:    8022,
	BaseCtr: dag.SSH().BaseContainer().WithServiceBinding("sshd", sshd),
})...

Note: When a Service is passed directly as a parameter to an external Dagger function, it does not bind to the container created inside the Dagger function. (Confirmed in v0.13.3)

Return Type
Container !
Example
dagger -m github.com/seungyeop-lee/daggerverse/ssh@05a5d11c78e35558e860540308c7dc73b370c795 call \
 base-container
func (m *myModule) example() *Container  {
	return dag.
			Ssh().
			BaseContainer()
}
@function
def example() -> dagger.Container:
	return (
		dag.ssh()
		.base_container()
	)
@func()
example(): Container {
	return dag
		.ssh()
		.baseContainer()
}

config() 🔗

Set configuration for SSH connections.

Return Type
Config !
Arguments
NameTypeDefault ValueDescription
destinationString !-destination to connect ex) user@host
portInteger 22port to connect
baseCtrContainer -base container
Example
dagger -m github.com/seungyeop-lee/daggerverse/ssh@05a5d11c78e35558e860540308c7dc73b370c795 call \
 config --destination string
func (m *myModule) example(destination string) *SshConfig  {
	return dag.
			Ssh().
			Config(destination)
}
@function
def example(destination: str) -> dag.SshConfig:
	return (
		dag.ssh()
		.config(destination)
	)
@func()
example(destination: string): SshConfig {
	return dag
		.ssh()
		.config(destination)
}

Config 🔗

SSH configuration

withPassword() 🔗

Set the password as the SSH connection credentials.

Return Type
Commander !
Arguments
NameTypeDefault ValueDescription
argSecret !-password
Example
dagger -m github.com/seungyeop-lee/daggerverse/ssh@05a5d11c78e35558e860540308c7dc73b370c795 call \
 config --destination string \
 with-password --arg env:MYSECRET
func (m *myModule) example(destination string, arg *Secret) *SshCommander  {
	return dag.
			Ssh().
			Config(destination).
			WithPassword(arg)
}
@function
def example(destination: str, arg: dagger.Secret) -> dag.SshCommander:
	return (
		dag.ssh()
		.config(destination)
		.with_password(arg)
	)
@func()
example(destination: string, arg: Secret): SshCommander {
	return dag
		.ssh()
		.config(destination)
		.withPassword(arg)
}

withIdentityFile() 🔗

Set up identity file with SSH connection credentials.

Note: Tested against RSA-formatted and OPENSSH-formatted private keys.

Return Type
Commander !
Arguments
NameTypeDefault ValueDescription
argSecret !-identity file
Example
dagger -m github.com/seungyeop-lee/daggerverse/ssh@05a5d11c78e35558e860540308c7dc73b370c795 call \
 config --destination string \
 with-identity-file --arg env:MYSECRET
func (m *myModule) example(destination string, arg *Secret) *SshCommander  {
	return dag.
			Ssh().
			Config(destination).
			WithIdentityFile(arg)
}
@function
def example(destination: str, arg: dagger.Secret) -> dag.SshCommander:
	return (
		dag.ssh()
		.config(destination)
		.with_identity_file(arg)
	)
@func()
example(destination: string, arg: Secret): SshCommander {
	return dag
		.ssh()
		.config(destination)
		.withIdentityFile(arg)
}

Commander 🔗

SSH command launcher

container() 🔗

Returns a container that is ready to launch SSH command.

Return Type
Container !
Example
dagger -m github.com/seungyeop-lee/daggerverse/ssh@05a5d11c78e35558e860540308c7dc73b370c795 call \
 config --destination string \
 with-identity-file --arg env:MYSECRET \
 container
func (m *myModule) example(destination string, arg *Secret) *Container  {
	return dag.
			Ssh().
			Config(destination).
			WithIdentityFile(arg).
			Container()
}
@function
def example(destination: str, arg: dagger.Secret) -> dagger.Container:
	return (
		dag.ssh()
		.config(destination)
		.with_identity_file(arg)
		.container()
	)
@func()
example(destination: string, arg: Secret): Container {
	return dag
		.ssh()
		.config(destination)
		.withIdentityFile(arg)
		.container()
}

command() 🔗

Run the command on the remote server.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
argString !-command
Example
dagger -m github.com/seungyeop-lee/daggerverse/ssh@05a5d11c78e35558e860540308c7dc73b370c795 call \
 config --destination string \
 with-identity-file --arg env:MYSECRET \
 command --arg string
func (m *myModule) example(destination string, arg *Secret, arg1 string) *Container  {
	return dag.
			Ssh().
			Config(destination).
			WithIdentityFile(arg).
			Command(arg1)
}
@function
def example(destination: str, arg: dagger.Secret, arg1: str) -> dagger.Container:
	return (
		dag.ssh()
		.config(destination)
		.with_identity_file(arg)
		.command(arg1)
	)
@func()
example(destination: string, arg: Secret, arg1: string): Container {
	return dag
		.ssh()
		.config(destination)
		.withIdentityFile(arg)
		.command(arg1)
}