lib/beaker/host/unix/exec.rb
# Sets the PermitUserEnvironment setting & restarts the SSH service.
#
# @api private
# @return [Result] result of the command restarting the SSH service
#   (from {#ssh_service_restart}).
Sets the PermitUserEnvironment setting & restarts the SSH service.
Sets the PermitUserEnvironment setting & restarts the SSH service .
def ssh_permit_user_environment
    case self['platform']
    when /debian|ubuntu|cumulus|huaweios|archlinux/
      directory = tmpdir()
      exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
      exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
      exec(Beaker::Command.new("echo '' >/etc/environment")) if self['platform'] =~ /ubuntu-20.04/
    when /el-7|centos-7|redhat-7|oracle-7|scientific-7|eos-7|el-8|centos-8|redhat-8|oracle-8/
      directory = tmpdir()
      exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
      exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
    when /el-|centos|fedora|redhat|oracle|scientific|eos/
      directory = tmpdir()
      exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
      exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
    when /sles/
      directory = tmpdir()
      exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
      exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
    when /solaris/
      directory = tmpdir()
      exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
      exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
    when /(free|open)bsd/
      exec(Beaker::Command.new("sudo perl -pi -e 's/^#?PermitUserEnvironment no/PermitUserEnvironment yes/' /etc/ssh/sshd_config"), {:pty => true} )
    else
      raise ArgumentError, "Unsupported Platform: '#{self['platform']}'"
    end
    ssh_service_restart()
  end
def ssh_permit_user_environment case self [ 'platform' ] when / debian|ubuntu|cumulus|huaweios|archlinux / directory = tmpdir ( ) exec ( Beaker :: Command . new ( "echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit" ) ) exec ( Beaker :: Command . new ( "mv #{directory}/sshd_config.permit /etc/ssh/sshd_config" ) ) exec ( Beaker :: Command . new ( "echo '' >/etc/environment" ) ) if self [ 'platform' ] =~ / ubuntu-20.04 / when / el-7|centos-7|redhat-7|oracle-7|scientific-7|eos-7|el-8|centos-8|redhat-8|oracle-8 / directory = tmpdir ( ) exec ( Beaker :: Command . new ( "echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit" ) ) exec ( Beaker :: Command . new ( "mv #{directory}/sshd_config.permit /etc/ssh/sshd_config" ) ) when / el-|centos|fedora|redhat|oracle|scientific|eos / directory = tmpdir ( ) exec ( Beaker :: Command . new ( "echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit" ) ) exec ( Beaker :: Command . new ( "mv #{directory}/sshd_config.permit /etc/ssh/sshd_config" ) ) when / sles / directory = tmpdir ( ) exec ( Beaker :: Command . new ( "echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit" ) ) exec ( Beaker :: Command . new ( "mv #{directory}/sshd_config.permit /etc/ssh/sshd_config" ) ) when / solaris / directory = tmpdir ( ) exec ( Beaker :: Command . new ( "echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit" ) ) exec ( Beaker :: Command . new ( "mv #{directory}/sshd_config.permit /etc/ssh/sshd_config" ) ) when / (free|open)bsd / exec ( Beaker :: Command . new ( "sudo perl -pi -e 's/^#?PermitUserEnvironment no/PermitUserEnvironment yes/' /etc/ssh/sshd_config" ) , { :pty => true } ) else raise ArgumentError , "Unsupported Platform: '#{self['platform']}'" end ssh_service_restart ( ) end
Sets the PermitUserEnvironment setting & restarts the SSH service.
Sets the PermitUserEnvironment setting & restarts the SSH service .
# kept solaris here because refactoring it into its own Host module # conflicts with the solaris hypervisor that already exists
result of the command restarting the SSH service (from {#ssh_service_restart}).
result of the command restarting the SSH service ( from { #ssh_service_restart } ) .
Result
api
None