# HG changeset patch # User RhodeCode Admin # Date 2023-01-11 13:32:50 # Node ID b8bab954f05a37f09e849d8a80ec90d2c0cf450c # Parent ecb70c81b429dd709b12a739c4fd3680b0347db8 ssh: generate tmp rename file in tmp dir rather then location of file. This is mostly due to possible docker mount permission issues diff --git a/rhodecode/apps/ssh_support/utils.py b/rhodecode/apps/ssh_support/utils.py --- a/rhodecode/apps/ssh_support/utils.py +++ b/rhodecode/apps/ssh_support/utils.py @@ -49,11 +49,12 @@ def get_all_active_keys(): def _generate_ssh_authorized_keys_file( authorized_keys_file_path, ssh_wrapper_cmd, allow_shell, ssh_opts, debug): + import rhodecode authorized_keys_file_path = os.path.abspath( os.path.expanduser(authorized_keys_file_path)) + tmp_file_dir = tempfile.gettempdir() - import rhodecode all_active_keys = get_all_active_keys() if allow_shell: @@ -73,8 +74,8 @@ def _generate_ssh_authorized_keys_file( line_tmpl = '{ssh_opts},command="{wrapper_command} {ini_path} --user-id={user_id} --user={user} --key-id={user_key_id}" {key}\n' fd, tmp_authorized_keys = tempfile.mkstemp( - '.authorized_keys_write', - dir=os.path.dirname(authorized_keys_file_path)) + '.authorized_keys_write_operation', + dir=tmp_file_dir) now = datetime.datetime.utcnow().isoformat() keys_file = os.fdopen(fd, 'wb')