Skip to the content.

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

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

Network setup

Same as WGET.PY — bring lwIP up first.

How it works

  1. Parse args → src / dst, infer direction
  2. Open TCP socket to host:port, settimeout(0.1)
  3. sess = _ssh.Session(s) — handshake
  4. sess.userauth_password(user, password)
  5. Either data = sess.scp_recv(remote_path) and write local, or read local and sess.scp_send(remote_path, mode, data)
  6. sess.close()

Limits

Source

View on GitHub: examples/scp.py