Skip to content

Commit 74b5e3f

Browse files
committed
Improvement: Remove deprecated users. Increased logging level for sshd.
1 parent d48770c commit 74b5e3f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ES.SFTP.Host/Controller.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private async Task ConfigureOpenSSH(SftpConfiguration configuration)
152152
builder.AppendLine("UseDNS no");
153153
builder.AppendLine();
154154
builder.AppendLine("# Logging");
155-
builder.AppendLine("LogLevel VERBOSE");
155+
builder.AppendLine("LogLevel INFO");
156156
builder.AppendLine();
157157
builder.AppendLine("# Subsystem");
158158
builder.AppendLine("Subsystem sftp internal-sftp");
@@ -216,6 +216,15 @@ private async Task SyncUsersAndGroups(SftpConfiguration configuration)
216216
await GroupUtil.GroupCreate(SftpGroup, true);
217217
}
218218

219+
var existingUsers = (await GroupUtil.GroupListUsers(SftpGroup));
220+
var toRemove = existingUsers.Where(s => !configuration.Users.Select(t => t.Username).Contains(s)).ToList();
221+
foreach (var user in toRemove)
222+
{
223+
_logger.LogDebug("Removing user '{user}'", user, SftpGroup);
224+
await UserUtil.UserDelete(user);
225+
}
226+
227+
219228
foreach (var user in configuration.Users)
220229
{
221230
_logger.LogInformation("Processing user '{user}'", user.Username);

0 commit comments

Comments
 (0)