LOG IN SIGN UP
Documentation

Log streaming: SFTP

Fastly's Real-Time Log Streaming feature can send log files to SFTP, a secure file transfer subsystem for the Secure Shell (SSH) protocol. Our SFTP endpoint supports both password-based authentication and SSH public-key authentication, with SSH public-key authentication being preferred. To learn more about SSH public-key authentication, or to learn how to generate public and private key pairs, see this guide.

Adding SFTP as a logging endpoint

To create an SFTP endpoint, run the following cURL command:

curl -s -X POST -H 'Fastly-Key: <your Fastly API key>' -H 'Content-Type: application/json' 'https://api.fastly.com/service/<your Fastly service ID>/version/<version number>/logging/sftp' --data-binary '{"name":"<log name>", "address":"<your hostname>", "port":"<port number>", "format":"%h %l %u %t %r %>s", "user":"<your username>", "secret_key":"<your secret key>"}'

Secret keys must be passed in "PEM" format. A PEM file is a base64 (ASCII) encoded block of data encapsulated between two delimiters, e.g. something that looks like:

-----BEGIN RSA PRIVATE KEY-----
....
-----END RSA PRIVATE KEY-----

To pass your secret key on the command line, you'll need to convert all the newlines to escaped \n characters, as shown in the example below.

curl -s -X POST -H 'Fastly-Key: <your Fastly API key>' -H 'Content-Type: application/json' 'https://api.fastly.com/service/<your Fastly service ID>/version/<version number>/logging/sftp' --data-binary '{"name":"<log name>", "address":"<your hostname>", "port":"22", "format":"%h %l %u %t %r %>s", "user":"<your username>", "secret_key":"-----BEGIN PRIVATE KEY-----\nMIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQCWAY2o6Rxh2NdT\nu509AvEeK9mWV7LVje/tFn1Mzf9t8nRhiLrL83N+u0NnZpnpPsI4lRT88Zi9fAj4\niMeSFJCf7dUdN259ZiubF/aWFdSZUaLOd8Jw1Z+L5Vgpc2sERN/N+UA/Sn6NEk2M\n6DliRuTYhwxajjpWIG206Noa66tYJAbbsuMRDA0B9b6avd2xQ4UkUWjFwNtwX5b3\nWhWoxtL/eVs7JPX8Ju0jfsGa13x8UcnMhojwzY7wDU3WURo/kp5LgeVY/r1p0fVZ\nRaDEcakA1ZMMqCr3DcEzFsMI5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iXefxfaY\nMvUF7zoQYsNjZEhHvwDCBWOdVVePENo+AijOE97QujScXw6cakN0T8xCYIGddzZp\nQypNTw8MSGu/ZeKyji9h5jZ62bc33FZTSBaE1WqUlCsCgYEAmKYqSAUWTkN2QrPq\nj9RrhfjSeekLok2u4VuylfH/vqcnlWLthUOdL9PtGD6hUOqaXP6INl3wZyIKja1a\nuG+3m9U7MRqkH1ecobtvGN/q1r8=\n-----END PRIVATE KEY-----"}'

Additional resources:


Back to Top