server session BUGFIX forgotten locked access
diff --git a/src/session_server_ssh.c b/src/session_server_ssh.c
index 4758c0d..ed48c29 100644
--- a/src/session_server_ssh.c
+++ b/src/session_server_ssh.c
@@ -406,6 +406,9 @@
 _nc_server_ssh_add_authkey(const char *pubkey_path, const char *pubkey_base64, NC_SSH_KEY_TYPE type,
                           const char *username)
 {
+    /* LOCK */
+    pthread_mutex_lock(&server_opts.authkey_lock);
+
     ++server_opts.authkey_count;
     server_opts.authkeys = nc_realloc(server_opts.authkeys, server_opts.authkey_count * sizeof *server_opts.authkeys);
     if (!server_opts.authkeys) {
@@ -417,6 +420,9 @@
     server_opts.authkeys[server_opts.authkey_count - 1].type = type;
     server_opts.authkeys[server_opts.authkey_count - 1].username = lydict_insert(server_opts.ctx, username, 0);
 
+    /* UNLOCK */
+    pthread_mutex_unlock(&server_opts.authkey_lock);
+
     return 0;
 }
 
@@ -638,6 +644,9 @@
     const char *username = NULL;
     int ret;
 
+    /* LOCK */
+    pthread_mutex_lock(&server_opts.authkey_lock);
+
     for (i = 0; i < server_opts.authkey_count; ++i) {
         switch (server_opts.authkeys[i].type) {
         case NC_SSH_KEY_UNKNOWN:
@@ -674,6 +683,9 @@
         username = server_opts.authkeys[i].username;
     }
 
+    /* UNLOCK */
+    pthread_mutex_unlock(&server_opts.authkey_lock);
+
     return username;
 }