diff --git a/Dockerfile.ci b/Dockerfile.ci
index a3e982614de69..9a0fea30ee625 100644
--- a/Dockerfile.ci
+++ b/Dockerfile.ci
@@ -909,6 +909,9 @@ function environment_initialization() {
     # Added to have run-tests on path
     export PATH=${PATH}:${AIRFLOW_SOURCES}
 
+    # Directory where simple auth manager store generated passwords
+    export AIRFLOW_AUTH_MANAGER_CREDENTIAL_DIRECTORY="/files"
+
     mkdir -pv "${AIRFLOW_HOME}/logs/"
 
     # Change the default worker_concurrency for tests
diff --git a/airflow/auth/managers/simple/simple_auth_manager.py b/airflow/auth/managers/simple/simple_auth_manager.py
index 4a9639a998c46..78dccf7c2a980 100644
--- a/airflow/auth/managers/simple/simple_auth_manager.py
+++ b/airflow/auth/managers/simple/simple_auth_manager.py
@@ -30,7 +30,7 @@
 from airflow.auth.managers.base_auth_manager import BaseAuthManager, ResourceMethod
 from airflow.auth.managers.simple.user import SimpleAuthManagerUser
 from airflow.auth.managers.simple.views.auth import SimpleAuthManagerAuthenticationViews
-from hatch_build import AIRFLOW_ROOT_PATH
+from airflow.configuration import AIRFLOW_HOME
 
 if TYPE_CHECKING:
     from airflow.auth.managers.models.base_user import BaseUser
@@ -78,20 +78,22 @@ class SimpleAuthManager(BaseAuthManager):
     :param appbuilder: the flask app builder
     """
 
-    # File that contains the generated passwords
-    GENERATED_PASSWORDS_FILE = (
-        AIRFLOW_ROOT_PATH / "generated" / "simple_auth_manager_passwords.json.generated"
-    )
-
     # Cache containing the password associated to a username
     passwords: dict[str, str] = {}
 
+    @staticmethod
+    def get_generated_password_file() -> str:
+        return os.path.join(
+            os.getenv("AIRFLOW_AUTH_MANAGER_CREDENTIAL_DIRECTORY", AIRFLOW_HOME),
+            "simple_auth_manager_passwords.json.generated",
+        )
+
     def init(self) -> None:
         user_passwords_from_file = {}
 
         # Read passwords from file
-        if os.path.isfile(self.GENERATED_PASSWORDS_FILE):
-            with open(self.GENERATED_PASSWORDS_FILE) as file:
+        if os.path.isfile(self.get_generated_password_file()):
+            with open(self.get_generated_password_file()) as file:
                 passwords_str = file.read().strip()
                 user_passwords_from_file = json.loads(passwords_str)
 
@@ -109,7 +111,7 @@ def init(self) -> None:
 
             self._print_output(f"Password for user '{user['username']}': {self.passwords[user['username']]}")
 
-        with open(self.GENERATED_PASSWORDS_FILE, "w") as file:
+        with open(self.get_generated_password_file(), "w") as file:
             file.write(json.dumps(self.passwords))
 
     def is_logged_in(self) -> bool:
diff --git a/scripts/docker/entrypoint_ci.sh b/scripts/docker/entrypoint_ci.sh
index d0946b39e0e28..a96e58b9c21a5 100755
--- a/scripts/docker/entrypoint_ci.sh
+++ b/scripts/docker/entrypoint_ci.sh
@@ -139,6 +139,9 @@ function environment_initialization() {
     # Added to have run-tests on path
     export PATH=${PATH}:${AIRFLOW_SOURCES}
 
+    # Directory where simple auth manager store generated passwords
+    export AIRFLOW_AUTH_MANAGER_CREDENTIAL_DIRECTORY="/files"
+
     mkdir -pv "${AIRFLOW_HOME}/logs/"
 
     # Change the default worker_concurrency for tests
diff --git a/tests/auth/managers/simple/test_simple_auth_manager.py b/tests/auth/managers/simple/test_simple_auth_manager.py
index d4bd4e4fbfed2..434c0d60fcc76 100644
--- a/tests/auth/managers/simple/test_simple_auth_manager.py
+++ b/tests/auth/managers/simple/test_simple_auth_manager.py
@@ -50,7 +50,7 @@ class TestSimpleAuthManager:
     @pytest.mark.db_test
     def test_init_with_no_user(self, auth_manager_with_appbuilder):
         auth_manager_with_appbuilder.init()
-        with open(SimpleAuthManager.GENERATED_PASSWORDS_FILE) as file:
+        with open(auth_manager_with_appbuilder.get_generated_password_file()) as file:
             passwords_str = file.read().strip()
             user_passwords_from_file = json.loads(passwords_str)
 
@@ -65,7 +65,7 @@ def test_init_with_users(self, auth_manager_with_appbuilder):
             }
         ]
         auth_manager_with_appbuilder.init()
-        with open(SimpleAuthManager.GENERATED_PASSWORDS_FILE) as file:
+        with open(auth_manager_with_appbuilder.get_generated_password_file()) as file:
             passwords_str = file.read().strip()
             user_passwords_from_file = json.loads(passwords_str)
 
diff --git a/tests/auth/managers/simple/views/test_auth.py b/tests/auth/managers/simple/views/test_auth.py
index a4e2a12fdcf1c..f61a9278f79a5 100644
--- a/tests/auth/managers/simple/views/test_auth.py
+++ b/tests/auth/managers/simple/views/test_auth.py
@@ -37,7 +37,7 @@ def simple_app():
             ): "airflow.auth.managers.simple.simple_auth_manager.SimpleAuthManager",
         }
     ):
-        with open(SimpleAuthManager.GENERATED_PASSWORDS_FILE, "w") as file:
+        with open(SimpleAuthManager.get_generated_password_file(), "w") as file:
             user = {"test": "test"}
             file.write(json.dumps(user))
 
