cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ro...@apache.org
Subject [cloudstack] branch master updated: CLOUDSTACK-10213: Allow specify SSH key lengh (#2389)
Date Tue, 09 Jan 2018 06:46:42 GMT
This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d0fa5e  CLOUDSTACK-10213: Allow specify SSH key lengh (#2389)
0d0fa5e is described below

commit 0d0fa5e3066300ff59a2e1680e5f15e5d83b78cb
Author: Dmytro Shevchenko <shevchenko_dmitry@ukr.net>
AuthorDate: Tue Jan 9 08:46:37 2018 +0200

    CLOUDSTACK-10213: Allow specify SSH key lengh (#2389)
    
    SSH keys generated by the ACS are only 1024 bit (RSA). The common standard is now at least
2048 bit.
---
 server/src/com/cloud/server/ManagementServerImpl.java      | 6 ++++--
 utils/src/main/java/com/cloud/utils/ssh/SSHKeysHelper.java | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 82a3752..cfc94e2 100644
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -696,6 +696,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
 
     static final ConfigKey<Integer> vmPasswordLength = new ConfigKey<Integer>("Advanced",
Integer.class, "vm.password.length", "6",
                                                                                       "Specifies
the length of a randomly generated password", false);
+    static final ConfigKey<Integer> sshKeyLength = new ConfigKey<Integer>("Advanced",
Integer.class, "ssh.key.length",
+            "2048", "Specifies custom SSH key length (bit)", true, ConfigKey.Scope.Global);
     @Inject
     public AccountManager _accountMgr;
     @Inject
@@ -3051,7 +3053,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
 
     @Override
     public ConfigKey<?>[] getConfigKeys() {
-        return new ConfigKey<?>[] {vmPasswordLength};
+        return new ConfigKey<?>[] {vmPasswordLength, sshKeyLength};
     }
 
     protected class EventPurgeTask extends ManagedContextRunnable {
@@ -3583,7 +3585,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
             throw new InvalidParameterValueException("A key pair with name '" + cmd.getName()
+ "' already exists.");
         }
 
-        final SSHKeysHelper keys = new SSHKeysHelper();
+        final SSHKeysHelper keys = new SSHKeysHelper(sshKeyLength.value());
 
         final String name = cmd.getName();
         final String publicKey = keys.getPublicKey();
diff --git a/utils/src/main/java/com/cloud/utils/ssh/SSHKeysHelper.java b/utils/src/main/java/com/cloud/utils/ssh/SSHKeysHelper.java
index 39db5c4..f80baaf 100644
--- a/utils/src/main/java/com/cloud/utils/ssh/SSHKeysHelper.java
+++ b/utils/src/main/java/com/cloud/utils/ssh/SSHKeysHelper.java
@@ -43,9 +43,9 @@ public class SSHKeysHelper {
         return sb.toString();
     }
 
-    public SSHKeysHelper() {
+    public SSHKeysHelper(Integer keyLength) {
         try {
-            keyPair = KeyPair.genKeyPair(new JSch(), KeyPair.RSA);
+            keyPair = KeyPair.genKeyPair(new JSch(), KeyPair.RSA, keyLength);
         } catch (JSchException e) {
             e.printStackTrace();
         }

-- 
To stop receiving notification emails like this one, please contact
['"commits@cloudstack.apache.org" <commits@cloudstack.apache.org>'].

Mime
View raw message