Class: ConfigBuilder::Model::SSH

Inherits:
Base
  • Object
show all
Defined in:
lib/config_builder/model/ssh.rb

Overview

Vagrant SSH credential model

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attr, #attrs=, #call, #configure!, def_model_attribute, def_model_delegator, def_model_id, def_model_option, #eval_models, #instance_id, #instance_options, model_attributes, model_delegators, #model_delegators, model_options, new_from_hash, #with_attr

Instance Attribute Details

#forward_agentBoolean

Returns If true, agent forwarding over SSH connections is enabled. Defaults to false.

Returns:

  • (Boolean)

    If true, agent forwarding over SSH connections is enabled. Defaults to false.



58
# File 'lib/config_builder/model/ssh.rb', line 58

def_model_attribute :forward_agent

#forward_envArray<String>

Returns An array of host environment variables to forward to the guest.

Returns:

  • (Array<String>)

    An array of host environment variables to forward to the guest.



68
# File 'lib/config_builder/model/ssh.rb', line 68

def_model_attribute :forward_env

#forward_x11Boolean

Returns If true, X11 forwarding over SSH connections is enabled. Defaults to false.

Returns:

  • (Boolean)

    If true, X11 forwarding over SSH connections is enabled. Defaults to false.



63
# File 'lib/config_builder/model/ssh.rb', line 63

def_model_attribute :forward_x11

#guest_portFixnum

Returns The port on the guest that SSH is running on. This is used by some providers to detect forwarded ports for SSH. For example, if this is set to 22 (the default), and Vagrant detects a forwarded port to port 22 on the guest from port 4567 on the host, Vagrant will attempt to use port 4567 to talk to the guest if there is no other option.

Returns:

  • (Fixnum)

    The port on the guest that SSH is running on. This is used by some providers to detect forwarded ports for SSH. For example, if this is set to 22 (the default), and Vagrant detects a forwarded port to port 22 on the guest from port 4567 on the host, Vagrant will attempt to use port 4567 to talk to the guest if there is no other option.



36
# File 'lib/config_builder/model/ssh.rb', line 36

def_model_attribute :guest_port

#hostString

Returns The hostname or IP to SSH into. By default this is empty, because the provider usually figures this out for you.

Returns:

  • (String)

    The hostname or IP to SSH into. By default this is empty, because the provider usually figures this out for you.



23
# File 'lib/config_builder/model/ssh.rb', line 23

def_model_attribute :host

#insert_keyBoolean

Returns If true, Vagrant will automatically insert an insecure keypair to use for SSH. By default, this is true. This only has an effect if you don't already use private keys for authentication.

Returns:

  • (Boolean)

    If true, Vagrant will automatically insert an insecure keypair to use for SSH. By default, this is true. This only has an effect if you don't already use private keys for authentication.



74
# File 'lib/config_builder/model/ssh.rb', line 74

def_model_attribute :insert_key

#keep_aliveBoolean

Returns:

  • (Boolean)


40
# File 'lib/config_builder/model/ssh.rb', line 40

def_model_attribute :keep_alive

#passwordString

Returns This sets a password that Vagrant will use to authenticate the SSH user. Note that Vagrant recommends you use key-based authentiation rather than a password (see #private_key_path) below. If you use a password, Vagrant will automatically insert a keypair if insert_key is true.

Returns:

  • (String)

    This sets a password that Vagrant will use to authenticate the SSH user. Note that Vagrant recommends you use key-based authentiation rather than a password (see #private_key_path) below. If you use a password, Vagrant will automatically insert a keypair if insert_key is true.



18
# File 'lib/config_builder/model/ssh.rb', line 18

def_model_attribute :password

#portFixnum

Returns The port to SSH into. By default this is port 22.

Returns:

  • (Fixnum)

    The port to SSH into. By default this is port 22.



27
# File 'lib/config_builder/model/ssh.rb', line 27

def_model_attribute :port

#private_key_pathString

Returns The path to the private key to use to SSH into the guest machine. By default this is the insecure private key that ships with Vagrant, since that is what public boxes use. If you make your own custom box with a custom SSH key, this should point to that private key.

You can also specify multiple private keys by setting this to be an array. This is useful, for example, if you use the default private key to bootstrap the machine, but replace it with perhaps a more secure key later.

Returns:

  • (String)

    The path to the private key to use to SSH into the guest machine. By default this is the insecure private key that ships with Vagrant, since that is what public boxes use. If you make your own custom box with a custom SSH key, this should point to that private key.

    You can also specify multiple private keys by setting this to be an array. This is useful, for example, if you use the default private key to bootstrap the machine, but replace it with perhaps a more secure key later.



53
# File 'lib/config_builder/model/ssh.rb', line 53

def_model_attribute :private_key_path

#proxy_commandString

Returns A command-line command to execute that receives the data to send to SSH on stdin. This can be used to proxy the SSH connection. %h in the command is replaced with the host and %p is replaced with the port.

Returns:

  • (String)

    A command-line command to execute that receives the data to send to SSH on stdin. This can be used to proxy the SSH connection. %h in the command is replaced with the host and %p is replaced with the port.



81
# File 'lib/config_builder/model/ssh.rb', line 81

def_model_attribute :proxy_command

#ptyBoolean

Returns If true, pty will be used for provisioning. Defaults to false.

This setting is an advanced feature that should not be enabled unless absolutely necessary. It breaks some other features of Vagrant, and is really only exposed for cases where it is absolutely necessary. If you can find a way to not use a pty, that is recommended instead.

Returns:

  • (Boolean)

    If true, pty will be used for provisioning. Defaults to false.

    This setting is an advanced feature that should not be enabled unless absolutely necessary. It breaks some other features of Vagrant, and is really only exposed for cases where it is absolutely necessary. If you can find a way to not use a pty, that is recommended instead.



91
# File 'lib/config_builder/model/ssh.rb', line 91

def_model_attribute :pty

#shellString

Returns The shell to use when executing SSH commands from Vagrant. By default this is bash -l. Note that this has no effect on the shell you get when you run vagrant ssh. This configuration option only affects the shell to use when executing commands internally in Vagrant.

Returns:

  • (String)

    The shell to use when executing SSH commands from Vagrant. By default this is bash -l. Note that this has no effect on the shell you get when you run vagrant ssh. This configuration option only affects the shell to use when executing commands internally in Vagrant.



99
# File 'lib/config_builder/model/ssh.rb', line 99

def_model_attribute :shell

#sudo_commandString

Returns The command to use when executing a command with sudo. This defaults to sudo -E -H %c. The %c will be replaced by the command that is being executed.

Returns:

  • (String)

    The command to use when executing a command with sudo. This defaults to sudo -E -H %c. The %c will be replaced by the command that is being executed.



105
# File 'lib/config_builder/model/ssh.rb', line 105

def_model_attribute :sudo_command

#usernameString

Returns This sets the username that Vagrant will SSH as by default. Providers are free to override this if they detect a more appropriate user. By default this is "vagrant," since that is what most public boxes are made as.

Returns:

  • (String)

    This sets the username that Vagrant will SSH as by default. Providers are free to override this if they detect a more appropriate user. By default this is "vagrant," since that is what most public boxes are made as.



10
# File 'lib/config_builder/model/ssh.rb', line 10

def_model_attribute :username

Instance Method Details

#to_procObject



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/config_builder/model/ssh.rb', line 107

def to_proc
  Proc.new do |global_config|
    ssh = global_config.ssh

    with_attr(:username)         { |val| ssh.username         = val }
    with_attr(:password)         { |val| ssh.password         = val }
    with_attr(:host)             { |val| ssh.host             = val }
    with_attr(:port)             { |val| ssh.port             = val }
    with_attr(:guest_port)       { |val| ssh.guest_port       = val }
    with_attr(:keep_alive)       { |val| ssh.keep_alive       = val }
    with_attr(:private_key_path) { |val| ssh.private_key_path = val }
    with_attr(:forward_agent)    { |val| ssh.forward_agent    = val }
    with_attr(:forward_x11)      { |val| ssh.forward_x11      = val }
    with_attr(:forward_env)      { |val| ssh.forward_env      = val }
    with_attr(:insert_key)       { |val| ssh.insert_key       = val }
    with_attr(:proxy_command)    { |val| ssh.proxy_command    = val }
    with_attr(:pty)              { |val| ssh.pty              = val }
    with_attr(:shell)            { |val| ssh.shell            = val }
    with_attr(:sudo_command)     { |val| ssh.sudo_command     = val }
  end
end