diff --git a/src/azure-cli/azure/cli/command_modules/acs/custom.py b/src/azure-cli/azure/cli/command_modules/acs/custom.py index 23a733c9bab..b443eee1343 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/custom.py @@ -2243,12 +2243,14 @@ def merge_kubernetes_configurations(existing_file, addition_file, replace, conte existing['current-context'] = addition['current-context'] # check that ~/.kube/config is only read- and writable by its owner - if platform.system() != 'Windows': - existing_file_perms = "{:o}".format( - stat.S_IMODE(os.lstat(existing_file).st_mode)) - if not existing_file_perms.endswith('600'): - logger.warning('%s has permissions "%s".\nIt should be readable and writable only by its owner.', - existing_file, existing_file_perms) + if platform.system() != "Windows" and not os.path.islink(existing_file): + existing_file_perms = "{:o}".format(stat.S_IMODE(os.lstat(existing_file).st_mode)) + if not existing_file_perms.endswith("600"): + logger.warning( + '%s has permissions "%s".\nIt should be readable and writable only by its owner.', + existing_file, + existing_file_perms, + ) with open(existing_file, 'w+') as stream: yaml.safe_dump(existing, stream, default_flow_style=False)