Always set PermitRootLogin for sshd_config
				
					
				
			it was only being set if the setting existed
This commit is contained in:
		
							parent
							
								
									38b99cd817
								
							
						
					
					
						commit
						4af428db78
					
				
					 1 changed files with 6 additions and 2 deletions
				
			
		|  | @ -71,11 +71,15 @@ def configure(allow_root=False): | |||
|     Configure the OpenSSH service | ||||
|     """ | ||||
|     path = '/etc/ssh/sshd_config' | ||||
|     value = 'without-password' if allow_root else 'no' | ||||
|     sed(path, r'^PermitRootLogin\s+.*', 'PermitRootLogin {}'.format(value), use_sudo=True) | ||||
| 
 | ||||
|     entry = 'PermitRootLogin {}'.format('without-password' if allow_root else 'no') | ||||
|     sed(path, r'^PermitRootLogin\s+.*', entry, use_sudo=True) | ||||
|     append(path, entry, use_sudo=True) | ||||
| 
 | ||||
|     entry = 'PasswordAuthentication no' | ||||
|     sed(path, r'^PasswordAuthentication\s+.*', entry, use_sudo=True) | ||||
|     append(path, entry, use_sudo=True) | ||||
| 
 | ||||
|     restart() | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar