Open Charging Technology · Whitepapers

SFTP for Logfile Uploads and Firmware Downloads

Version 0.3, Draft, 2026-11-13 CC-BY-SA 4.0 · OpenChargingTechnology/Whitepapers · reference implementations (in part, chapter 12): Vanaheimr/Hermod (SSH stack, SFTP client and server), OpenChargingCloud/WWCP_Node (SSH peers, SFTP areas), OpenChargingCloud/WWCP_OCPP, OpenChargingCloud/ChargingStation, OpenChargingCloud/LocalController, OpenChargingCloud/CSMS

OCPP lets a CSMS ask a charging station to upload its logs and diagnostics to a URL, and to download its firmware from one. The URL names the protocol, and SFTP is one of them. What OCPP does not say is how the station knows that the server which answers at that URL is the one that was meant. Over HTTPS and FTPS a certificate chain answers that, well or badly. Over SFTP nothing does: the request carries a host name, a port, a login and a path, and no host key.

A station that dials whatever host a request names and takes whatever host key it is shown hands its logs to anybody who can write that request or sit on that path, and takes its firmware from the same. This paper closes the gap without a new message:

This holds for GetLog in all its log types, for GetDiagnostics of OCPP 1.6, for UpdateFirmware and SignedUpdateFirmware, and for PublishFirmware at a Local Controller. To this paper a diagnostics log, a security log and a firmware image are files to be moved, and nothing more: what is in them, how they are made and what is done with them is OCPP's and the vendor's.

Status: a draft for discussion. Chapter 12 says what the reference implementations have of it today, and chapter 13 what was decided on 2026-11-13 and which questions are open.

Contents

  1. Motivation
  2. Design
  3. The URL
  4. File servers are SSH peers
  5. From the request to the transfer
  6. Uploads
  7. Downloads
  8. Configuration and the OCPP Device Model
  9. The station's keys
  10. The file server
  11. Security considerations
  12. Implementation status
  13. Decisions and open questions
  14. Relation to other white papers

1. Motivation

1.1 What OCPP says

Message OCPP Direction of the file Where the URL is
GetDiagnostics 1.6 station → server location
GetLog 1.6 (security extension), 2.x station → server log.remoteLocation
UpdateFirmware 1.6 server → station location
SignedUpdateFirmware 1.6 (security extension) server → station firmware.location
UpdateFirmware 2.x server → station firmware.location
PublishFirmware 2.x, to a Local Controller server → Local Controller location

The station says which protocols it speaks in OCPPCommCtrlr.FileTransferProtocols (OCPP 2.x: FTP, FTPS, HTTP, HTTPS, SFTP) or SupportedFileTransferProtocols (OCPP 1.6). The credentials, where there are any, travel in the URL. The outcome is reported by LogStatusNotification, DiagnosticsStatusNotification, FirmwareStatusNotification, SignedFirmwareStatusNotification and PublishFirmwareStatusNotification.

1.2 What is missing

An sftp:// URL names a host, a port, a login and a path. An SSH client needs two more things, and OCPP has a place for neither:

1.3 Why trust on first use is no answer here

For its OCPP connection a station may learn a host key on first use, on probation, until a signed pin set confirms it (OCPP over SSH, section 10.4). That works because the connection lasts: there is time to confirm, and the station executes nothing before. A file transfer is over before anybody could confirm anything. The log is gone, or the firmware image is on the station, at the moment the question would be asked.

And the two directions have different victims:

1.4 Non-goals


2. Design

2.1 Principles

  1. The request chooses among servers, it never introduces one. Which servers exist, what they may show and what they may be used for is configuration. The URL of a request picks one of them, a login and a path.
  2. The configuration can be better protected than the request. A CSMS that may send GetLog need not be able to make a file server out of any host by the same right: the peers are written as the station's signature policy says, and enforced, by a signed request only (section 8.4, decision 3).
  3. Checked before answered. Everything that can be decided without the network is decided before the response, so that a refusal is a Rejected and not a failure some minutes later.
  4. No softening. Trust on first use, OnPinMismatch Record and Accept, and probation do not exist for file transfers. A host key that no pin and no CA vouches for ends the transfer.
  5. Keys, not passwords. The station signs in with a key it made itself and never gave away.
  6. One model for all nodes. A Local Controller downloads a published firmware image by the same rules, and a CSMS that fetches a file from another server would too.
  7. A file is a file. The transport is handed a file and a place to put it, or a place and somewhere to put the file. A DiagnosticsLog, a SecurityLog and a firmware image differ in who makes or uses them, which is OCPP's logic and the vendor's, and in nothing the transport sees. So a file server is allowed uploads, downloads or both, and not log types.

2.2 Decisions and rejected alternatives

Chosen Rejected, and why
Where the host key comes from the station's SSH peer configuration the URL (;fingerprint=), customData of the request: trust would come from the very message that is to be checked
Trust on first use never on probation, as for OCPP: nobody can confirm in time (section 1.3)
Connection of its own, closed after the transfer; a channel of the station's connection to that peer where the peer says Shared and the login is that connection's (decision 4) one way only: a station that dials its Local Controller over SSH has a believed connection there already, and a file server of somebody else has none
Credential a key per file server and login (decision 2) one SFTP key for all file servers: every server could tell which other logins are the same station's, and one key withdrawn would be all of them withdrawn; a password from the URL (question 1)
A missing peer Rejected in the response accepted and failed later: the CSMS would learn it by a time-out
Scope of a file server per peer: which directions, which logins, which paths every peer for everything: a time server would become a place to send logs to
What is transferred a file, whatever it is a grant per log type, an archive format, a signature check: OCPP's logic and the vendor's, not the transport's

3. The URL

OCPP gives the location as a URL. For SFTP this paper reads it as the expired but widely implemented draft-ietf-secsh-scp-sftp-ssh-uri does:

sftp://[<user>[;fingerprint=<fingerprint>]@]<host>[:<port>]/<path>

For an upload the path names a directory; the station chooses the file name and reports it (section 6.2). For a download it names the file.


4. File servers are SSH peers

4.1 The lookup

A station that speaks SSH has SSH peers: hosts it holds a host key for, by pins or by a CA (OCPP over SSH, sections 7.2 and 7.3). A file server is one of them, with a few variables more (section 8.1). The request is answered from four lookups, all of them in the station's own configuration:

Question Answered by
1 Is there a peer with this host and port? Address, Port
2 May this peer be used in this direction? FileTransfers
3 May the station sign in there under this login? FileTransferUsers, UserName
4 May a file go to, or come from, this path? UploadPaths, DownloadPaths

Only when all four say yes does the station take from the same peer what it needs to dial:

4.2 What a peer is not allowed to be

4.3 Address and port

An SSH peer has one address and one port, and a station has one peer per address, as it keeps one connection to a host (OCPP over SSH, section 7.3). A request finds its file server by both: the host of the URL is the address of the peer, and the port of the URL - 22 where it names none - is the port of the peer. The right host on another port is no file server.

So an SFTP server on a second port of a host that is a peer already, with a host key of its own, cannot be a second peer under that address. It is entered under a name or address of its own, or it waits for peers that are found by address and port (question 5).


5. From the request to the transfer

5.1 Before the response

sequenceDiagram
    participant CSMS
    participant CS as Charging station
    participant FS as File server
    CSMS->>CS: GetLog(remoteLocation = sftp://cs001@logs.example.org/upload/cs001/)
    Note over CS: scheme, host, port, login, path<br/>→ peer? transfer allowed? login? path?<br/>pinned? key at hand?
    CS-->>CSMS: Accepted, filename
    CS->>CSMS: LogStatusNotification(Uploading)
    CS->>FS: SSH: key exchange (strict KEX)
    Note over CS: host key ∈ pins, or signed by a pinned CA?
    CS->>FS: publickey(cs001, SFTP key)
    CS->>FS: subsystem sftp: write <name>.part, rename
    CS->>FS: disconnect
    CS->>CSMS: LogStatusNotification(Uploaded)

The station answers Rejected when

  1. the URL is no valid sftp:// URL as chapter 3 reads it, or carries a password;
  2. no peer has that host and port;
  3. the peer does not allow this direction, this login or this path;
  4. the peer's host key is not pinned (section 4.2), or a ;fingerprint= of the URL contradicts it;
  5. the station has no key for this login at this peer, or the key is not confirmed as enrolled (chapter 9) - unless the transfer is a channel of a connection that lasts (section 5.3).

OCPP 2.x responses carry a statusInfo, with one of two reason codes:

reasonCode Cases
InvalidURL 1 The request is malformed, and saying so discloses nothing.
FileServerNotPermitted 2 to 5 One code for all of them: the response does not say which hosts the station knows and which logins it has. The station's own log and the security event (section 8.5) say exactly what was missing.

Requests without a status in their response are answered as their version allows:

Request Refusal
GetLog (1.6, 2.x) Rejected
UpdateFirmware (2.x), SignedUpdateFirmware (1.6) Rejected
PublishFirmware (2.x) Rejected
GetDiagnostics (1.6) a response without fileName, then DiagnosticsStatusNotification UploadFailed
UpdateFirmware (1.6) the empty response, then FirmwareStatusNotification DownloadFailed

Every refusal of the cases 2 to 5 is a security event: somebody with the right to send requests asked the station to move a file to or from a place its configuration does not know.

5.2 The connection

  1. Resolve the host name with the station's own resolvers (Secure Name Resolution), never those of the operating system.
  2. Connect and exchange keys, with the algorithms and the strict KEX of OCPP over SSH, section 11.2.
  3. Check the host key: it is one of HostKeyPins, or a host certificate for the host name of the URL signed by one of HostCAs, valid and not revoked. Anything else ends the connection before the authentication starts, and nothing of the station is sent to that server.
  4. Sign in with publickey, the login of the request and the key of that login at that peer. Nothing else is offered: no password, no keyboard-interactive, no other key of the station.
  5. Open one session channel with the subsystem sftp. No shell, no exec, no forwarding is asked for, and none a server offers is taken.
  6. Transfer (chapters 6 and 7).
  7. Disconnect. The connection is not kept for a next request.

One transfer runs at a time per direction. A second GetLog while an upload is running cancels the first, as OCPP says (AcceptedCanceled); the same holds for UpdateFirmware.

5.3 As a channel of a connection that is there

A station that dials its Local Controller or its CSMS over SSH keeps a connection to it whose host key it believes and whose login it is (OCPP over SSH, section 7.2). Where that host is also the file server, a second connection would prove the same things again. So a peer may say FileTransferConnection Shared (section 8.1), and then:

5.4 Failures and retries

retries and retryInterval of the request are for what may be better a minute later, and for nothing else:

What happened Retried Upload reported as Download reported as Security event
name not resolved, connection refused or timed out, connection lost yes UploadFailure after the last try DownloadFailed after the last try -
no common algorithm, no strict KEX no UploadFailure DownloadFailed InvalidSSHAlgorithms
host key neither pinned nor signed by a pinned CA no UploadFailure DownloadFailed InvalidFileServerHostKey
login refused no PermissionDenied DownloadFailed FailedToAuthenticateAtFileServer
no sftp subsystem no NotSupportedOperation DownloadFailed -
SSH_FX_PERMISSION_DENIED, SSH_FX_NO_SUCH_FILE no PermissionDenied DownloadFailed -
the name of the upload, or its .part, is taken no UploadFailure - -
quota, disk full, other SSH_FX_FAILURE yes UploadFailure after the last try DownloadFailed after the last try -

A wrong host key is final for the request. A retry would only ask the same attacker again, and a server whose key really changed needs a new pin, not a new attempt. OCPP 1.6 has fewer status values; there every failed upload is UploadFailed.


6. Uploads

6.1 What is covered

GetLog with every logType (DiagnosticsLog, SecurityLog, and DataCollectorLog of OCPP 2.1), and GetDiagnostics of OCPP 1.6. To the transport they are one thing: a file of the station, sent away.

6.2 What the transport is given, and what it does

The logic above it - OCPP's and the vendor's - decides what the file is: which log, of which time window, one file or an archive of several, signed or not. It hands the transport a file and its name, and the name is what the response of the request reports. The transport does the rest:


7. Downloads

7.1 What is covered

UpdateFirmware of OCPP 1.6 and 2.x, SignedUpdateFirmware of OCPP 1.6, and PublishFirmware at a Local Controller. To the transport they are one thing: a file of a server, fetched.

7.2 What the transport does, and what it hands over

7.3 What the transport does not replace

The host key authenticates the server, not the file. A believed server may hold an old image with a known weakness, or a wrong one, and a server that was taken over serves what it likes. Whether an image is genuine and whether it may be installed is decided after the download, by the signature and the version, in OCPP's logic and the vendor's. For the unsigned UpdateFirmware of OCPP 1.6 the transport gives what it can - a server the station believed, a login that server knows - and that is more than http:// and ftp:// give, and less than a signature.

7.4 A Local Controller

PublishFirmware asks a Local Controller to fetch an image and to offer it to its stations. Both halves fit this paper:

In the other direction a Local Controller can be the file server its stations upload to, and pass the files on. That is storage and forwarding on the Local Controller, and not specified here.


8. Configuration and the OCPP Device Model

8.1 Per peer: SSHPeerController

The instances of SSHPeerController (OCPP over SSH, section 7.3) get seven variables more:

Variable Name req/opt Mutability Data Type Default Value Values List / Limits Description
FileTransfers optional rw MemberList "" Upload, Download The directions this peer may be used in as a file server, whatever the file is. Empty: it is none.
FileTransferUsers optional rw string "" comma separated, ≤ 8, each ≤ 32 characters The logins a request may name. Empty: only UserName, or the station's own identity where that is empty too.
UploadPaths optional rw string "" comma separated, ≤ 8, each ≤ 255 characters Directories an upload may go to, each with everything below it. Empty: none, even where FileTransfers has Upload. An operator who wants security logs apart from diagnostics names two directories, and the CSMS sends each request to its own.
DownloadPaths optional rw string "" comma separated, ≤ 8, each ≤ 255 characters Directories a download may come from, each with everything below it. Empty: none.
FileTransferConnection optional rw OptionList Dedicated Dedicated, Shared Shared: a request whose login is the login of the station's connection to this peer goes as one more channel of it (section 5.3). Dedicated: every transfer has a connection of its own.
FileTransferPublicKeys optional ro string "" comma separated, one per login The public keys the station signs in with for file transfers at this peer, one per login (chapter 9): each a line of authorized_keys whose comment is <login>@<peer>, so that the list says which key is whose.
FileTransferKeyStates optional ro string "" comma separated, one per login Whether the key of each login is used, as <login>=Unconfirmed or <login>=Confirmed. Unconfirmed: made and shown, and not used until somebody confirmed that the file server holds it.

{id} in a path stands for the station's identity, so that one value serves a fleet: UploadPaths /upload/{id}/.

The keys and their states are lists of the peer, and not a variable instance per login: the instances of this component are its peers, and a login comes and goes with FileTransferUsers. In the configuration file all of it is the fileTransfers object of the peer's entry:

{ "id": "files", "address": "logs.example.org", "port": 2222,
  "hostKeyPins": [ "SHA256:hOEj1ea61PSArpO3/qj2Drlp024D2eiJ7DJQNNLl+hU" ],
  "fileTransfers": {
    "directions":    [ "upload", "download" ],
    "users":         [ "cs001" ],
    "uploadPaths":   [ "/upload/{id}/" ],
    "downloadPaths": [ "/firmware/" ]
  } }

The variables this paper relies on and does not change: Address, Port, UserName, HostKeyPins, HostCAs. OnPinMismatch is not read for a file transfer.

A peer of a station that speaks OCPP over a WebSocket and SSH for nothing but its files:

Variable Value
SSHPeerController.Peers files
SSHPeerController[files].Address logs.example.org
SSHPeerController[files].Port 2222
SSHPeerController[files].HostKeyPins SHA256:hOEj1ea61PSArpO3/qj2Drlp024D2eiJ7DJQNNLl+hU
SSHPeerController[files].FileTransfers Upload,Download
SSHPeerController[files].FileTransferUsers cs001
SSHPeerController[files].UploadPaths /upload/{id}/
SSHPeerController[files].DownloadPaths /firmware/
SSHPeerController[files].FileTransferPublicKeys ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI… cs001@files (read only)
SSHPeerController[files].FileTransferKeyStates cs001=Confirmed (read only)

With it, sftp://cs001@logs.example.org:2222/upload/cs001/ is a place for logs, and sftp://cs001@logs.example.org:2222/firmware/station-4.2.1.bin a place firmware comes from. sftp://cs001@logs.example.org/upload/cs001/ is neither: port 22 is not the port of that peer.

8.2 Station-wide

Component Variable Mutability Data Type Default Description
OCPPCommCtrlr FileTransferProtocols ro MemberList - Lists SFTP when the station can speak it, whether or not a peer is a file server yet.
SSHPeerController FileTransferConnectTimeout rw integer (s) 30 From the first packet to the open sftp channel.
SSHPeerController FileTransferIdleTimeout rw integer (s) 60 Without a byte moving, a transfer counts as lost (and is retried).
SSHPeerController FileTransferMaxDownloadSize rw integer (bytes) station-specific A file larger than this is not downloaded.

8.3 OCPP 1.6

SupportedFileTransferProtocols lists SFTP. The SSH peers have their configuration keys in OCPP over SSH, section 9.5: sshPeers, and per peer sshPeer.<name>.url, .hostKeyPins, .hostCAs and the others. A file server has seven more, named and read like the variables of section 8.1:

Key Accessibility Example
sshPeer.name.fileTransfers rw "Upload,Download"
sshPeer.name.fileTransferUsers rw "cs001"
sshPeer.name.uploadPaths rw "/upload//"
sshPeer.name.downloadPaths rw "/firmware/"
sshPeer.name.fileTransferConnection rw "Dedicated"
sshPeer.name.fileTransferPublicKeys ro "ssh-ed25519 AAAA… cs001@files"
sshPeer.name.fileTransferKeyStates ro "cs001=Confirmed"

A peer is added by its url with its pins, as that section says, and is no file server until fileTransfers is written. The station-wide values of section 8.2 are sshPeers.fileTransferConnectTimeout, sshPeers.fileTransferIdleTimeout and sshPeers.fileTransferMaxDownloadSize. What "rw" means over OCPP 1.6 is section 8.4.

8.4 Who may write the peers

A CSMS that could add a peer with SetVariables and name it in a GetLog a second later would have configured nothing in advance. The rule of this paper is only as strong as the write of the peer:

There is no rule of its own for file servers, and none that is built into the component (decision 3): a station has one policy, which can be set to allow everything, as it has to talk to a CSMS that signs nothing. What this paper asks of an operator is therefore a setting, and not a property of the protocol:

8.5 Security events

Security event Critical When
FileTransferRefused yes A request named a file server, a login or a path the configuration does not allow (section 5.1, cases 2 to 5). TechInfo: the action, the URL without its userinfo, and what was missing.
InvalidFileServerHostKey yes A file server showed a host key that neither a pin nor a CA vouches for. TechInfo: the peer, the fingerprint shown.
FailedToAuthenticateAtFileServer no The file server did not take the station's key.
InvalidSSHAlgorithms yes (OCPP over SSH) Only algorithms the station must not use, or no strict KEX.
ReconfigurationOfSecurityParameters no (existing) A peer became a file server, ceased to be one, or what it allows changed.

9. The station's keys

9.1 A key per file server and login

The station signs in at a file server with a key of its own for that login at that server (decision 2): one Ed25519 key pair for every entry of FileTransferUsers of every peer, made by the station itself, kept where only its own process may read it, and never exported. This is the purpose SFTP of OCPP over SSH, section 10.1, which is a family of keys here and not one key:

9.2 Enrolment

Which login the station uses at a file server, and which key, is the station's to say and the CSMS's to read. Nothing of it is a secret: the login is one of FileTransferUsers, and the key is the public half. The private half is never read by anybody.

What the CSMS needs Where it reads it
The logins the station signs in under at this file server SSHPeerController[<peer>].FileTransferUsers; where that is empty, UserName of the peer, or the station's identity
The public key of each login SSHPeerController[<peer>].FileTransferPublicKeys: one line of authorized_keys per login, comma separated, each with the comment <login>@<peer>
Whether the station uses that key already SSHPeerController[<peer>].FileTransferKeyStates: <login>=Unconfirmed or <login>=Confirmed
The next key of a login, during a rotation SSHPeerController[<peer>].FileTransferPendingPublicKeys (section 9.3)

A GetVariables or a GetReport for the component SSHPeerController returns all of them: the list of logins and public keys of every file server the station has.

sequenceDiagram
    participant CSMS
    participant CS as Charging station
    participant FS as File server
    CSMS->>CS: SetVariables (signed): peer "files", pins,<br/>FileTransfers, FileTransferUsers = cs001, paths
    Note over CS: makes a key pair for cs001 at "files"
    CSMS->>CS: GetVariables(FileTransferPublicKeys of "files")
    CS-->>CSMS: ssh-ed25519 AAAA… cs001@files
    CSMS->>FS: enter the line into authorized_keys of cs001
    CSMS->>CS: SSHKeySigned(SFTP, publicKey, peer = files, login = cs001)
    Note over CS: FileTransferKeyStates = cs001=Confirmed
    CSMS->>CS: GetLog(sftp://cs001@logs.example.org:2222/upload/cs001/)
    CS->>FS: publickey(cs001), sftp
  1. The login is configured. With the peer, or later: a login added to FileTransferUsers has a key pair made for it at once, and its state is Unconfirmed.
  2. The CSMS learns the key. It reads FileTransferPublicKeys, or is sent it: the station sends a SignSSHKey (below) on a TriggerMessage, and by itself when a login is added.
  3. The CSMS enters the key at the file server, where that login lives: in its own store, by InstallSSHKey at a Local Controller, in the authorized_keys of an OpenSSH server, or by having it certified (section 9.5). How it reaches a file server of somebody else is not OCPP's.
  4. The CSMS confirms it with SSHKeySigned, naming the key, the peer and the login. The station checks that this is the key it holds for that login at that file server, and from then on uses it: its entry in FileTransferKeyStates is Confirmed. Another key, another login, a file server that is none, or only one of the two names, confirm nothing. An account on the station itself may confirm a key as well, on its web interface or its command line, where an installer entered it by hand.
  5. Not used before. Until then a request for that login is rejected (section 5.1, case 5): the server would refuse the login anyway, and the CSMS reads why in FileTransferKeyStates.

The messages are those of OCPP over SSH, section 9.3, with two optional fields:

Message Field Type Card. Description
SignSSHKey, SSHKeySigned peer string[0..50] 0..1 With the purpose SFTP: the name of the file server, as in SSHPeerController.Peers.
SignSSHKey, SSHKeySigned login string[0..32] 0..1 With the purpose SFTP: the login the key is for.

TriggerMessage asks for a SignSSHKey with the customTrigger SignSSHKey:SFTP:<peer>:<login>; SignSSHKey:SFTP alone asks for one message per login of every file server. A trigger that names a login the station has at no file server is Rejected. Over OCPP 1.6 and 2.0.1 the messages travel as DataTransfer, as that paper says, and the keys are read by GetConfiguration (section 8.3).

A CSMS that wants a login to use a key it knows already cannot have that: a key is made on the station, for one login at one file server, and what the CSMS decides is the login and where the public half is entered.

9.3 Rotation

As OCPP over SSH, section 10.3, per key: the new key is shown in FileTransferPendingPublicKeys, a list as FileTransferPublicKeys is, its state in FileTransferKeyStates is <login>=Rotating, and it is sent with SignSSHKey; after SSHKeySigned the station offers the new key first and the old one second. As a file transfer connects rarely, the old key is kept until the first transfer succeeded with the new one, or the CSMS withdraws it.

9.4 The key of a shared connection

A transfer that is a channel of the station's connection to the peer (section 5.3) was signed in with that connection's key, the station's own (Station). No key of this chapter is made for the login of that connection unless it is also listed in FileTransferUsers for a peer that is Dedicated.

9.5 Certificates

A user certificate for a key, returned in SSHKeySigned, lets a file server trust one CA line in place of a line per station and login (OCPP over SSH, section 10.5).


10. The file server

Any SFTP server will do. What it should be, for this paper to hold what it promises:

Requirement
Logins One per station, named in the URL. A fleet login shared by all stations lets each station write as any other.
Authentication publickey only, with the key the station made for that login at this server, or a certificate for it.
What a login may do The sftp subsystem, and nothing else: no shell, no exec, no forwarding, no agent.
Uploads A directory per station that takes new files and nothing else: no listing, no reading, no overwriting, no deleting, no renaming but of the station's own .part file, and that never over a file. A quota. A station that cannot see whether a name is taken learns it from the open or the rename.
Downloads Read-only, and only the images that station may have.
Host key Stable, and announced to the stations (as a pin) before it changes: two pins for the time of a change. Or a host certificate of a CA the stations hold.
What arrives Is untrusted input: a file name and a file from a device in the field.

A sketch for OpenSSH, untested:

# /etc/ssh/sshd_config
Match Group stations
    ChrootDirectory /srv/stations/%u
    ForceCommand internal-sftp -u 0077
    AuthenticationMethods publickey
    PasswordAuthentication no
    AllowTcpForwarding no
    AllowAgentForwarding no
    X11Forwarding no
    PermitTTY no

with /srv/stations/cs001 owned by root, an upload directory in it the station may write to, and a firmware directory it may only read. OpenSSH alone does not make a directory write-only; a mover that takes finished files out of upload gives nearly the same.

In the reference implementations a node's SSH server already serves virtual SFTP areas per role (logs and logos). An upload area per station and a firmware area, for logins of the purpose SFTP, are two more areas of the same kind on a Local Controller and a CSMS; the .part name is held as the .filepart of WinSCP is today.


11. Security considerations

11.1 What this is against

Attacker Without this paper With it
On the path between station and file server answers the handshake, receives the logs, serves the firmware shows a host key the station does not hold; the transfer ends before anything is sent
Controls DNS for the server's name the same, from anywhere the same as above: the name was only a way to the pinned key
Can send OCPP requests (a CSMS taken over, a Local Controller, a stolen operator account) names their own server in GetLog and collects the logs of the fleet with the signature policy enforced: is refused in the response, and reported, unless they can also sign as a role with the right to the connections. With the policy off: can add a file server of their own, pinned to their own host key (section 8.4)
Took over an approved file server has what is uploaded from then on, and serves what they like unchanged for uploads: the peer was believed. A firmware image is still held to its signature, by the logic above (section 7.3)
Has the key of one login at one file server signs in as that login, there can write into that station's upload directory and read its firmware, and nothing else, if the server is as chapter 10 says

11.2 What it is not against

11.3 Rules that are easy to get wrong


12. Implementation status

12.1 What is built

On the master branches of the reference implementations:

Repository Commits What
Hermod aa42d703 (pull request #255) uploads from a stream that never write over a file; downloads into a stream from an offset, with a limit checked before the first byte; a failed read is the end of a file no longer; an exception of its own for a host key that was refused
WWCP_Node 8f56b25, 03948309 the URL of chapter 3; a file server as an SSH peer of the configuration with a fileTransfers object (section 8.1); the judgement of sections 4.1 and 5.1; a key per file server and login, used once confirmed and deleted with its login (sections 9.1, 9.2); uploads and downloads on a connection of their own or as a channel (sections 5.2, 5.3), and how each ends (section 5.4)
WWCP_OCPP 10ed9951, 7ec2079f GetLog and UpdateFirmware of OCPP 2.1, and GetLog, GetDiagnostics, UpdateFirmware and SignedUpdateFirmware of OCPP 1.6, answered and told as chapters 5 to 7 say, with the retries and the cancellation of a request; a provider of the file to upload and a consumer of the file that was downloaded; the security events FileTransferRefused and InvalidFileServerHostKey
WWCP_OCPP df25a599 the seven variables of section 8.1 at SSHPeerController and the keys of section 8.3, carried through every change of the peers
WWCP_OCPP 9bfa9d93 peer and login in SignSSHKey and SSHKeySigned, as JSON and as CBOR (section 9.2)
ChargingStation c51a4218 the custom triggers SignSSHKey:SFTP:<peer>:<login> and SignSSHKey:SFTP; an SSHKeySigned that names a file server and a login confirms that key, and nothing else does
WWCP_OCPP, ChargingStation cfbe26fb, 41a3ee4e SSHPeerController and the keys sshPeers and sshPeer.* of OCPP 1.6 belong to the connections for the signature policy, with what makes a peer a file server (section 8.4); the check by pin set signers that df25a599 had built into the component is gone

Tested in each of them, the transfers against a second node as the SFTP server and the enrolment at a charging station against a CSMS over SSH; the suites around the tests are green.

12.2 What is not built, or differs from this paper

Today This paper
The station sends a key by itself only on a TriggerMessage; a CSMS reads it in FileTransferPublicKeys otherwise when a login is added (section 9.2)
The CSMS does not enter a key at a file server, and does not send SSHKeySigned with a peer and a login section 9.2
SignSSHKey over OCPP 1.6 and 2.0.1 the messages exist for OCPP 2.1 only as DataTransfer (section 9.2)
Rotation a login has one key, and no pending one; there is no FileTransferPendingPublicKeys, and no state Rotating section 9.3
The one SFTP key the station still makes and rotates it, and nothing signs in with it; SignSSHKey:SFTP rotates it while there is no file server not used (section 9.1)
Station-wide variables the time-outs and the download limit are properties of the node and of the bridge, and no variables section 8.2
FileTransferProtocols the station nodes of WWCP_OCPP list HTTPS lists SFTP (section 8.2)
PublishFirmware not answered section 7.4
Host certificates judged by the code that judges a time server's; not tested for a file server section 5.2
No strict KEX, no common algorithm the first is told apart; the second ends as unreachable, and is tried again InvalidSSHAlgorithms, not tried again (section 5.4)
A refusal of GetDiagnostics and UpdateFirmware in OCPP 1.6 the notification follows the response after a quarter of a second, and not by a guarantee of the order chapter 5
The charging station and the Local Controller neither provides a file nor takes one: a request that passes every check is rejected for want of a file, and a download stays in its staging directory chapters 6 and 7
The web interface and the command line show neither file servers nor their keys; a key is confirmed over OCPP or by code section 8.4, section 9.2
The file server of a node SFTP areas for accounts (logs, logos); no upload and no firmware area. An upload under <name>.filepart is held and put in place over a file of that name; <name>.part is a file like any other chapter 10
InstallSSHKey with the purpose SFTP the Local Controller installs keys of the station's own purpose only section 9.2
OpenSSH no run against it yet chapter 10

13. Decisions and open questions

13.1 Decisions

Decided on 2026-11-13:

  1. Where file servers live: they are instances of SSHPeerController, and of nothing else, found by address and port. A Local Controller the station dials over ssh://, whose pins are in SSHClientController today, is entered there as well to be a file server (section 4.1, section 8.1).
  2. Keys: one key per file server and login, made by the station (chapter 9). The one key of the purpose SFTP is not used for file transfers; SignSSHKey and SSHKeySigned say which peer and login a key is for.
  3. Who writes the peers over OCPP: the station's signature policy says, for SSHPeerController as for every other component, and for what makes a peer a file server as for the rest of it (section 8.4). Enforced, a write needs the signature of a role with the right to the station's connections; off, it is taken unsigned, as a station has to talk to a CSMS that signs nothing. Two earlier answers of the same day - file servers written signed only, then every SSH peer written signed only, by a check built into the component - are replaced by this one.
  4. Connections: a connection of its own, or - where the peer says Shared and the login is the one of the station's connection to it - a channel of that connection (sections 5.2, 5.3).
  5. What a file is: a diagnostics log, a security log and a firmware image are files to be transferred, and everything else about them is OCPP's logic and the vendor's (section 2.1, principle 7). So a file server is allowed directions and not log types (section 8.1), and the transport packs no archive and checks no signature (sections 6.2, 7.3).

13.2 Open questions

  1. A password in the URL. Proposed: rejected. The alternative is a switch per peer, AllowPassword, for servers of others that take no keys.
  2. OnPinMismatch Record on a test bench. Proposed: no exception; a test bench pins its key like everybody else.
  3. A Local Controller as file server for its stations' uploads (section 7.4): now, or after the download half? Proposed: after.
  4. Standardization. The reason codes, the security events, the variables and the two fields of SignSSHKey are proposals for OCPP, together with OCPP over SSH.
  5. Two SSH servers on one host. A peer is found by its address, so a file server on another port of a host that is a peer already needs a name of its own (section 4.3). Proposed: left as it is until somebody has such a host.

14. Relation to other white papers

References

License

© 2026 GraphDefined GmbH

This document is published under the Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA 4.0). You are free to share, adapt, and build upon it, even for commercial purposes, as long as you give appropriate credit and distribute your work and contributions under the same license.

Verbatim quotations from the OCPP specifications remain © Open Charge Alliance and are subject to their license (CC BY-ND 4.0).