Skip to content

Commit

Permalink
Fix the mila init command on windows
Browse files Browse the repository at this point in the history
Fixes mila-iqia#63

Signed-off-by: Fabrice Normandin <[email protected]>
  • Loading branch information
lebrice committed Nov 2, 2023
1 parent 244bd50 commit b30d4c7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions milatools/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,17 +408,20 @@ def init():
for entry in os.listdir(sshdir)
):
if yn("You have no public keys. Generate one?"):
# TODO: need to get the location of the key as an output of this command!
here.run("ssh-keygen")
else:
exit("No public keys.")

# Check that it is possible to connect using the key

if not here.check_passwordless("mila"):
if yn(
"Your public key does not appear be registered on the cluster. Register it?"
):
here.run("ssh-copy-id", "mila")
if yn("Your public key does not appear be registered on the cluster. Register it?"):
# NOTE: If we're on a Windows machine, we do something different here:
if sys.platform == "win32":
here.run('cat ~/.ssh/id_rsa.pub | ssh mila "cat >> ~/.ssh/authorized_keys"')
else:
here.run("ssh-copy-id", "mila")
if not here.check_passwordless("mila"):
exit("ssh-copy-id appears to have failed")
else:
Expand Down

0 comments on commit b30d4c7

Please sign in to comment.