Skip to content

Commit dc588b2

Browse files
committed
Fix for SSH Host Keys not being generated into the import directory
1 parent 884e764 commit dc588b2

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

ES.SFTP.Host/Controller.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ private async Task ImportOrCreateHostKeyFiles()
118118
if (!Directory.Exists(SshHostKeysDirPath))
119119
Directory.CreateDirectory(SshHostKeysDirPath);
120120

121+
122+
foreach (var hostKeyFile in HostKeyFiles)
123+
{
124+
var filePath = Path.Combine(SshHostKeysDirPath, hostKeyFile.Key);
125+
if (File.Exists(filePath)) continue;
126+
_logger.LogDebug("Generating host key file '{file}'", filePath);
127+
var keygenArgs = string.Format(hostKeyFile.Value, filePath);
128+
await ProcessUtil.QuickRun("ssh-keygen", keygenArgs);
129+
}
130+
121131
foreach (var file in Directory.GetFiles(SshHostKeysDirPath))
122132
{
123133
var targetFile = Path.Combine(SshDirectoryPath, Path.GetFileName(file));
@@ -127,14 +137,6 @@ private async Task ImportOrCreateHostKeyFiles()
127137
await ProcessUtil.QuickRun("chmod", $"700 \"{targetFile}\"");
128138
}
129139

130-
foreach (var hostKeyFile in HostKeyFiles)
131-
{
132-
var filePath = Path.Combine(SshDirectoryPath, hostKeyFile.Key);
133-
if (File.Exists(filePath)) continue;
134-
_logger.LogDebug("Generating host key file '{file}'", filePath);
135-
var keygenArgs = string.Format(hostKeyFile.Value, filePath);
136-
await ProcessUtil.QuickRun("ssh-keygen", keygenArgs);
137-
}
138140
}
139141

140142
private async Task ConfigureOpenSSH(SftpConfiguration configuration)

0 commit comments

Comments
 (0)