mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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.
This commit is contained in:
parent
981286f93c
commit
0d0fa5e306
@ -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",
|
static final ConfigKey<Integer> vmPasswordLength = new ConfigKey<Integer>("Advanced", Integer.class, "vm.password.length", "6",
|
||||||
"Specifies the length of a randomly generated password", false);
|
"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
|
@Inject
|
||||||
public AccountManager _accountMgr;
|
public AccountManager _accountMgr;
|
||||||
@Inject
|
@Inject
|
||||||
@ -3051,7 +3053,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfigKey<?>[] getConfigKeys() {
|
public ConfigKey<?>[] getConfigKeys() {
|
||||||
return new ConfigKey<?>[] {vmPasswordLength};
|
return new ConfigKey<?>[] {vmPasswordLength, sshKeyLength};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class EventPurgeTask extends ManagedContextRunnable {
|
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.");
|
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 name = cmd.getName();
|
||||||
final String publicKey = keys.getPublicKey();
|
final String publicKey = keys.getPublicKey();
|
||||||
|
|||||||
@ -43,9 +43,9 @@ public class SSHKeysHelper {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SSHKeysHelper() {
|
public SSHKeysHelper(Integer keyLength) {
|
||||||
try {
|
try {
|
||||||
keyPair = KeyPair.genKeyPair(new JSch(), KeyPair.RSA);
|
keyPair = KeyPair.genKeyPair(new JSch(), KeyPair.RSA, keyLength);
|
||||||
} catch (JSchException e) {
|
} catch (JSchException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user