#87 new: auto ask add system key (~/.ssh/id_rsa)

This commit is contained in:
lollipopkit
2023-08-04 21:46:44 +08:00
parent 60507ea4bc
commit 91967e6ce3
19 changed files with 129 additions and 76 deletions

View File

@@ -77,13 +77,12 @@ String pathJoin(String path1, String path2) {
return path1 + (path1.endsWith('/') ? '' : '/') + path2;
}
String getHome() {
String? home = "";
Map<String, String> envVars = Platform.environment;
if (isMacOS ||isLinux) {
home = envVars['HOME'];
String? getHomeDir() {
final envVars = Platform.environment;
if (isMacOS || isLinux) {
return envVars['HOME'];
} else if (isWindows) {
home = envVars['UserProfile'];
return envVars['UserProfile'];
}
return home??"";
return null;
}

View File

@@ -32,14 +32,14 @@ enum GenSSHClientStatus {
}
String getPrivateKey(String id) {
final key = locator<PrivateKeyStore>().get(id);
if (key == null) {
final pki = locator<PrivateKeyStore>().get(id);
if (pki == null) {
throw SSHErr(
type: SSHErrType.noPrivateKey,
message: 'key [$id] not found',
);
}
return key.privateKey;
return pki.key;
}
Future<SSHClient> genClient(