SCP.PY — SCP client
A pure-MicroPython SCP-1 client wrapping
_ssh.Session. Transfers single files
between DOS and a remote server using SSH (scp protocol).
Source: examples/scp.py.
Usage
MP.EXE SCP.PY [-P PORT] [-u USER] [-p PASS] SRC DST
Direction is auto-detected from which arg has the host:/path
colon.
Examples
REM Download:
MP.EXE SCP.PY user@10.0.2.2:/etc/motd MOTD.TXT
REM Upload:
MP.EXE SCP.PY DATA.BIN user@10.0.2.2:/uploads/data.bin
REM Explicit user / port / password:
MP.EXE SCP.PY -P 2222 -u alice -p secret SRC.TXT alice@host:/dst.txt
Flags
-P PORT— SSH port (default 22)-u USER— login user (defaulttestuserfor the rig)-p PASS— password (defaulttestpassfor the rig)
The default user / pass match the bundled SSH rig fixture
(rigs/ssh-rig/ssh_server.py) so the example works out of the box
against the rig server.
Path conventions
user@host:/path— absolute path on remotehost:/path— defaults user to flag valuepath(no colon) — local file
Network setup
Same as WGET.PY — bring lwIP up first.
How it works
- Parse args → src / dst, infer direction
- Open TCP socket to
host:port,settimeout(0.1) sess = _ssh.Session(s)— handshakesess.userauth_password(user, password)- Either
data = sess.scp_recv(remote_path)and write local, or read local andsess.scp_send(remote_path, mode, data) sess.close()
Limits
- Single file per invocation (no
-rrecursive) - Password auth only (Ed25519 publickey works at the API level —
the bundled script doesn’t expose it as a flag yet; see the
rigs/ssh-rig/SSHTEST.PYfor the publickey pattern) - Mode hardcoded to
0644forscp_send(a libssh2 snprintf formatter bug under uc386 that we patched around — see WIP.md) - The remote must speak SCP protocol (most do; OpenSSH does, dropbear does)
Source
View on GitHub:
examples/scp.py