mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	only create new sshkey if user is cloud
This commit is contained in:
		
							parent
							
								
									f0c4980dff
								
							
						
					
					
						commit
						b20147a4b4
					
				@ -552,12 +552,15 @@ public class ConfigurationServerImpl implements ConfigurationServer {
 | 
			
		||||
    protected void updateKeyPairs() {
 | 
			
		||||
        // Grab the SSH key pair and insert it into the database, if it is not present
 | 
			
		||||
 | 
			
		||||
        if (s_logger.isInfoEnabled()) {
 | 
			
		||||
            s_logger.info("Processing updateKeyPairs");
 | 
			
		||||
        String userid = System.getProperty("user.name");
 | 
			
		||||
        if (!userid.startsWith("cloud")){
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        String already = _configDao.getValue("ssh.privatekey");
 | 
			
		||||
        String homeDir = Script.runSimpleBashScript("echo ~");
 | 
			
		||||
        String userid = System.getProperty("user.name");
 | 
			
		||||
        if (s_logger.isInfoEnabled()) {
 | 
			
		||||
            s_logger.info("Processing updateKeyPairs");
 | 
			
		||||
        }
 | 
			
		||||
        if (homeDir != null && homeDir.equalsIgnoreCase("~")) {
 | 
			
		||||
            s_logger.error("No home directory was detected.  Set the HOME environment variable to point to your user profile or home directory.");
 | 
			
		||||
            throw new CloudRuntimeException("No home directory was detected.  Set the HOME environment variable to point to your user profile or home directory.");
 | 
			
		||||
@ -629,14 +632,8 @@ public class ConfigurationServerImpl implements ConfigurationServer {
 | 
			
		||||
                s_logger.info("Keypairs already in database, skip updating local copy (not running as cloud user)");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        
 | 
			
		||||
        if (userid.startsWith("cloud")){
 | 
			
		||||
            s_logger.info("Going to update systemvm iso with generated keypairs if needed");
 | 
			
		||||
            injectSshKeysIntoSystemVmIsoPatch(pubkeyfile.getAbsolutePath(), privkeyfile.getAbsolutePath());
 | 
			
		||||
        } else {
 | 
			
		||||
            s_logger.info("Skip updating keypairs on systemvm iso (not running as cloud user)");
 | 
			
		||||
        }
 | 
			
		||||
        s_logger.info("Going to update systemvm iso with generated keypairs if needed");
 | 
			
		||||
        injectSshKeysIntoSystemVmIsoPatch(pubkeyfile.getAbsolutePath(), privkeyfile.getAbsolutePath());
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private void writeKeyToDisk(String key, String keyPath) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user