ваше сообщение коммита

This commit is contained in:
2025-12-06 12:34:14 +03:00
parent 90da3a0d12
commit e9610881c8
20 changed files with 820 additions and 421 deletions

View File

@@ -13,7 +13,10 @@ const createUserWithSshKeys = async (username, publicKey, options) => {
// Настройка SSH ключей для пользователя
await execSshCommand(`mkdir -p /home/${username}/.ssh`, options);
await execSshCommand(`echo "${publicKey}" > /home/${username}/.ssh/authorized_keys`, options);
// Используем printf для безопасной обработки специальных символов в ключе
// Экранируем обратные слеши и знаки доллара в публичном ключе
const escapedPublicKey = publicKey.replace(/\\/g, '\\\\').replace(/\$/g, '\\$');
await execSshCommand(`printf '%s\\n' "${escapedPublicKey}" > /home/${username}/.ssh/authorized_keys`, options);
await execSshCommand(`chown -R ${username}:${username} /home/${username}/.ssh`, options);
await execSshCommand(`chmod 700 /home/${username}/.ssh`, options);
await execSshCommand(`chmod 600 /home/${username}/.ssh/authorized_keys`, options);