diff --git a/jupyter_sshd_proxy/__init__.py b/jupyter_sshd_proxy/__init__.py index 6ce9442..f05f763 100644 --- a/jupyter_sshd_proxy/__init__.py +++ b/jupyter_sshd_proxy/__init__.py @@ -25,7 +25,10 @@ def setup_sshd() -> Dict[str, Any]: # Last login info is from /var/log/lastlog, which is transient in containerized systems '-o', 'PrintLastLog no', '-o', f'AuthorizedKeysFile {AUTHORIZED_KEYS_PATH}', - '-o', f'LogLevel {SSHD_LOG_LEVEL}' + '-o', f'LogLevel {SSHD_LOG_LEVEL}', + # Default to enabling sftp + '-o', 'Subsystem sftp internal-sftp' + ] return { diff --git a/tests/test_ssh.py b/tests/test_ssh.py index 233ecd6..80fdc9a 100644 --- a/tests/test_ssh.py +++ b/tests/test_ssh.py @@ -97,3 +97,25 @@ def test_ssh_interactive(jupyter_server): proc.wait() assert proc.exitstatus == 0 + +# Test for both the sftp protocol (default on newer scp) ("-s"), and the older +# scp protocol ("-O"). +@pytest.mark.parametrize("extra_scp_args", [["-s"], ["-O"]]) +def test_scp(jupyter_server, extra_scp_args): + with tempfile.NamedTemporaryFile() as f, tempfile.TemporaryDirectory() as d: + file_contents = secrets.token_hex() + f.write(file_contents.encode()) + f.flush() + + target_path = os.path.join(d, "target") + + cmd = [ + 'scp', '-v', + ] + extra_scp_args + [f"-o={o}" for o in get_ssh_client_options(*jupyter_server)] + [ + f.name, f'127.0.0.1:{target_path}' + ] + + proc = subprocess.run(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE) + + with open(target_path) as tpf: + assert tpf.read() == file_contents \ No newline at end of file