Skip to content

Commit 5a7c534

Browse files
committed
Added support for ECDSA SSH keys.
Added support for ECDSA SSH keys. Closes bastillion-io#94
1 parent 4e48480 commit 5a7c534

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/main/java/com/keybox/manage/action/AuthKeysAction.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,12 @@ public String downloadPvtKey() {
228228
public String generateUserKey(String username, String keyname) {
229229

230230
//set key type
231-
int type = SSHUtil.KEY_TYPE.equals("rsa") ? KeyPair.RSA : KeyPair.DSA;
231+
int type = KeyPair.RSA;
232+
if(SSHUtil.KEY_TYPE.equals("dsa")) {
233+
type = KeyPair.DSA;
234+
} else if(SSHUtil.KEY_TYPE.equals("ecdsa")) {
235+
type = KeyPair.ECDSA;
236+
}
232237

233238
JSch jsch = new JSch();
234239

src/main/java/com/keybox/manage/util/SSHUtil.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,12 @@ public static String keyGen(String passphrase) {
167167
if (StringUtils.isEmpty(AppConfig.getProperty("privateKey")) || StringUtils.isEmpty(AppConfig.getProperty("publicKey"))) {
168168

169169
//set key type
170-
int type = KEY_TYPE.equals("rsa") ? KeyPair.RSA : KeyPair.DSA;
170+
int type = KeyPair.RSA;
171+
if(SSHUtil.KEY_TYPE.equals("dsa")) {
172+
type = KeyPair.DSA;
173+
} else if(SSHUtil.KEY_TYPE.equals("ecdsa")) {
174+
type = KeyPair.ECDSA;
175+
}
171176
String comment = "keybox@global_key";
172177

173178
JSch jsch = new JSch();
@@ -623,6 +628,8 @@ public static String getKeyType(String publicKey){
623628
keyType="DSA";
624629
} else if (KeyPair.RSA == type){
625630
keyType="RSA";
631+
} else if (KeyPair.ECDSA == type){
632+
keyType="ECDSA";
626633
} else if(KeyPair.UNKNOWN ==type){
627634
keyType="UNKNOWN";
628635
} else if(KeyPair.ERROR == type){

src/main/resources/KeyBoxConfig.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#
55
#set to true to regenerate and import SSH keys
66
resetApplicationSSHKey=false
7-
#SSH Key Type 'dsa' or 'rsa' for generated keys
7+
#SSH key type 'dsa', 'rsa', or 'ecdsa' for generated keys
88
sshKeyType=rsa
9-
#SSH Key Length for generated keys
9+
#SSH key length for generated keys. 2048 => 'rsa','dsa'; 521 => 'ecdsa'
1010
sshKeyLength=2048
1111
#private ssh key, leave blank to generate key pair
1212
privateKey=

0 commit comments

Comments
 (0)