Skip to content

Commit

Permalink
[Core] Make sure the Include ~/.sky/generated/ssh/* is added in `~/…
Browse files Browse the repository at this point in the history
….ssh/config` for empty config (#3069)

Make sure the `Include ~/.sky/generated/ssh/*` is added
  • Loading branch information
Michaelvll authored Feb 1, 2024
1 parent efef3bd commit 5710737
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,20 +495,23 @@ def add_cluster(

# Handle Include on top of Config file
include_str = f'Include {cls.ssh_cluster_path.format("*")}'
found = False
for i, line in enumerate(config):
config_str = line.strip()
if config_str == include_str:
found = True
break
# Did not find Include string. Insert `Include` lines.
if 'Host' in config_str:
with open(config_path, 'w') as f:
config.insert(
0,
f'# Added by SkyPilot for ssh config of all clusters\n{include_str}\n'
)
f.write(''.join(config).strip())
f.write('\n' * 2)
break
if not found:
# Did not find Include string. Insert `Include` lines.
with open(config_path, 'w') as f:
config.insert(
0,
f'# Added by SkyPilot for ssh config of all clusters\n{include_str}\n'
)
f.write(''.join(config).strip())
f.write('\n' * 2)

proxy_command = auth_config.get('ssh_proxy_command', None)

Expand Down

0 comments on commit 5710737

Please sign in to comment.