Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/agent/deploy-static/deploy_static_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
STATIC_FILE = 'https://backend-ai-k8s-agent-static.s3.ap-northeast-2.amazonaws.com/bai-static.tar.gz'

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.RejectPolicy())

for ip in sys.argv[1:]:
ssh.connect(ip)
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With RejectPolicy enabled, ssh.connect(ip) will raise a paramiko SSHException for unknown/mismatched host keys and this script will exit with a traceback. Consider catching the host-key-related exception(s) and printing a clear actionable message (e.g., how to provision/update known_hosts for the target IP) so failures are easier to diagnose during deployments.

Suggested change
ssh.connect(ip)
try:
ssh.connect(ip)
except paramiko.BadHostKeyException as exc:
print(
f'Failed to connect to {ip}: the host key does not match the entry in known_hosts. '
f'Remove or update the stale key for this host and retry. Details: {exc}',
file=sys.stderr,
)
print(
f'Example: ssh-keygen -R {ip} && ssh-keyscan -H {ip} >> ~/.ssh/known_hosts',
file=sys.stderr,
)
sys.exit(1)
except paramiko.SSHException as exc:
print(
f'Failed to connect to {ip}: SSH host key verification failed or the host key is not present in known_hosts. '
f'Add the correct host key for this host and retry. Details: {exc}',
file=sys.stderr,
)
print(
f'Example: ssh-keyscan -H {ip} >> ~/.ssh/known_hosts',
file=sys.stderr,
)
sys.exit(1)

Copilot uses AI. Check for mistakes.
Expand Down
Loading