@@ -118,6 +118,16 @@ private async Task ImportOrCreateHostKeyFiles()
118
118
if ( ! Directory . Exists ( SshHostKeysDirPath ) )
119
119
Directory . CreateDirectory ( SshHostKeysDirPath ) ;
120
120
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
+
121
131
foreach ( var file in Directory . GetFiles ( SshHostKeysDirPath ) )
122
132
{
123
133
var targetFile = Path . Combine ( SshDirectoryPath , Path . GetFileName ( file ) ) ;
@@ -127,14 +137,6 @@ private async Task ImportOrCreateHostKeyFiles()
127
137
await ProcessUtil . QuickRun ( "chmod" , $ "700 \" { targetFile } \" ") ;
128
138
}
129
139
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
- }
138
140
}
139
141
140
142
private async Task ConfigureOpenSSH ( SftpConfiguration configuration )
0 commit comments