--- admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/utils/user_ssh_access_pool.py +++ admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/utils/user_ssh_access_pool.py @@ -267,10 +267,18 @@ class UserSSHAccessPool(object): """ with server.runner() as runner: assert isinstance(runner, BaseRunner) + + # Some servers do no allow to login by SSH if user has no password. So we generate a random password + # (which is not used by migrator) for all new users. That password is not plain text password + # so it can't be used directly (see "man useradd" for details). + random_password = "".join(random.choice(string.digits + string.ascii_letters) for _ in range(24)) + runner.sh( + # $(cat) means to read the password from stdin u'useradd {username} ' - u'-m -g {gid} -o -u {uid} -s /bin/sh', - dict(username=username, uid=uid, gid=gid) + u'-m -g {gid} -o -u {uid} -s /bin/sh -p $(cat)', + dict(username=username, uid=uid, gid=gid), + stdin_content=random_password ) # CageFS is a CloudLinux feature which allows to restrict access to files of other users.