@@ -80,16 +80,6 @@ def configure_remoting(platform, remoting_config_path, password)
8080 command = "vagrant ssh-config > \" #{ remoting_config_path } \" "
8181 run_local_command ( command , @vagrant_env )
8282 remoting_config = Net ::SSH ::Config . load ( remoting_config_path , 'default' )
83- case platform
84- when %r{debian.*|ubuntu.*}
85- restart_command = 'service ssh restart'
86- when %r{sles-11.*|(centos|redhat|oracle)-[56].*}
87- restart_command = 'service sshd restart'
88- when %r{centos.*|redhat.*|oracle.*|sles.*}
89- restart_command = 'systemctl restart sshd.service'
90- else
91- raise ArgumentError , "Unsupported Platform: '#{ platform } '"
92- end
9383 # Pre-configure sshd on the platform prior to handing back
9484 ssh_params = {
9585 port : remoting_config [ 'port' ] ,
@@ -104,6 +94,15 @@ def configure_remoting(platform, remoting_config_path, password)
10494 ) do |session |
10595 session . exec! ( 'sudo su -c "cp -r .ssh /root/."' )
10696 session . exec! ( 'sudo su -c "sed -i \"s/.*PermitUserEnvironment\s.*/PermitUserEnvironment yes/g\" /etc/ssh/sshd_config"' )
97+ systemctl = session . exec! ( 'which systemctl 2>/dev/null' )
98+ restart_command = if systemctl . strip . empty?
99+ # Debian and Ubuntu use 'ssh' and the EL/Suse family use 'sshd'. This will catch either.
100+ 'service ssh restart || service sshd restart'
101+ else
102+ # On Debian/Ubuntu sshd is an alias to the 'ssh' service, and on the EL/Suse families
103+ # 'sshd' is the service name, so 'sshd.service' works for all:
104+ 'systemctl restart sshd.service'
105+ end
107106 session . exec! ( "sudo su -c \" #{ restart_command } \" " )
108107 end
109108 else
0 commit comments