blob: 9760bb0f6dbcfbbaa7872005b4049a9eeb4ba360 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import logging
import os
import shutil
def env_setup(ctx):
logging.info("setting up test directory for router testing")
srcdir = globals()["srcdir"]
# Copy env/ssh/ from source dir, which has SSH config and keys.
ssh = os.path.join(srcdir, "env", "ssh")
dst = os.path.join(os.getcwd(), ".ssh")
logging.debug(f"copy {ssh} to {dst}")
shutil.copytree(ssh, dst)
# The config refers to ssh/ed25519 as the key to use. However, the
# directory is actually .ssh here so that the SSH client finds it
# automatically. Create a symlink so both forms work.
os.symlink(".ssh", "ssh")
# Set permissions on the key files, so that the SSH client isn't upset if
# they're lax. Git doesn't preserve the permissions correctly.
os.chmod(".ssh/ed25519", 0o600)
os.chmod(".ssh/ed25519.pub", 0o600)
|