Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AddKeysToAgent for ssh config file and ssh cmd #3985

Merged
Show file tree
Hide file tree
Changes from 2 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
24 changes: 24 additions & 0 deletions examples/mpirun_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
workdir: .
zpoint marked this conversation as resolved.
Show resolved Hide resolved

resources:
cloud: aws

num_nodes: 2 # Total number of nodes (1 head + 1 worker)

setup: |
echo "Running setup on node ${SKYPILOT_NODE_RANK}."
# Install MPI if not already present. This will vary based on your OS/distro.
sudo apt update
sudo apt install -y openmpi-bin openmpi-common libopenmpi-dev

run: |
if [ "${SKYPILOT_NODE_RANK}" == "0" ]; then
echo "head node"
num_nodes=`echo "$SKYPILOT_NODE_IPS" | wc -l`
mpi_nodes=$(echo "$SKYPILOT_NODE_IPS" | tr '\n' ',')
mpi_nodes=${mpi_nodes::-1}
echo "$mpi_nodes"
mpirun -np $num_nodes -H $mpi_nodes bash -c 'echo "mpirun hello from IP $(hostname -I)"'
else
echo "worker nodes"
fi
1 change: 1 addition & 0 deletions sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ def _get_generated_config(cls, autogen_comment: str, host_name: str,
HostName {ip}
User {username}
IdentityFile {ssh_key_path}
AddKeysToAgent yes
IdentitiesOnly yes
ForwardAgent yes
StrictHostKeyChecking no
Expand Down
2 changes: 2 additions & 0 deletions sky/provision/provisioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ def _ssh_probe_command(ip: str,
'-o',
'IdentitiesOnly=yes',
'-o',
'AddKeysToAgent=yes',
'-o',
'ExitOnForwardFailure=yes',
'-o',
'ServerAliveInterval=5',
Expand Down
4 changes: 4 additions & 0 deletions sky/utils/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def ssh_options_list(
'LogLevel': 'ERROR',
# Try fewer extraneous key pairs.
'IdentitiesOnly': 'yes',
# Add the current private key to the agent so that agent forwarding
# will forward the key used for authentication instead of the system
# default in the user's home directory.
'AddKeysToAgent': 'yes',
# Abort if port forwarding fails (instead of just printing to
# stderr).
'ExitOnForwardFailure': 'yes',
Expand Down
Loading