Skip to content

Connect from the command line and scripts ​

bash
# upload a file
echo "put build.zip" | sftp -b - Xy12AbCd.deploy@sftp.repoforge.io

# download a file
sftp Xy12AbCd.deploy@sftp.repoforge.io:report.csv .

# download everything in your home folder
sftp -r Xy12AbCd.deploy@sftp.repoforge.io:/ ./backup

Replace Xy12AbCd.deploy with the username you were given: the organisation's account ID, a dot and your name. The server listens on the standard SSH port, 22.

Before you run any of these in a script, add the server's host key to your known_hosts file, as described on the host key fingerprints page, so the connection can't be intercepted.

sftp ​

The sftp command is included with macOS, Linux and Windows 10 and later.

bash
# open an interactive session
sftp Xy12AbCd.deploy@sftp.repoforge.io

# use a particular key
sftp -i ~/.ssh/repoforge_sftp Xy12AbCd.deploy@sftp.repoforge.io

# run several commands from a file or a here-document, stopping at the first error
sftp -b - Xy12AbCd.deploy@sftp.repoforge.io <<'EOF'
mkdir releases
put build.zip releases/build-1.4.2.zip
ls -l releases
EOF

# upload a folder
echo "put -r dist" | sftp -b - Xy12AbCd.deploy@sftp.repoforge.io

-b (batch mode) never prompts, so it only works with key logins. With a password, run sftp interactively, or use curl or paramiko below.

scp and rsync ​

scp and rsync aren't supported. Use sftp instead; the commands at the top of this page cover the same uploads and downloads.

curl ​

curl can upload and download over SFTP when it's built with SFTP support. Run curl -V and check that sftp is in the list of protocols. (The curl that comes with macOS doesn't include it.)

bash
# upload with a key
curl -u Xy12AbCd.deploy: --key ~/.ssh/repoforge_sftp --pubkey ~/.ssh/repoforge_sftp.pub \
  -T build.zip sftp://sftp.repoforge.io/build.zip

# download with a password
curl -u 'Xy12AbCd.deploy:your-password' -o report.csv sftp://sftp.repoforge.io/report.csv

Paths after the hostname are from your home folder.

Python (paramiko) ​

python
import paramiko

client = paramiko.SSHClient()
# refuses to connect unless sftp.repoforge.io is in ~/.ssh/known_hosts
client.load_system_host_keys()
client.connect(
    "sftp.repoforge.io",
    username="Xy12AbCd.deploy",
    key_filename="/home/me/.ssh/repoforge_sftp",
    # or password="your-password",
)

sftp = client.open_sftp()
sftp.put("build.zip", "build.zip")
sftp.get("report.csv", "report.csv")
print(sftp.listdir("."))
client.close()

Install it with pip install paramiko.

PowerShell ​

Windows 10 and later include the OpenSSH sftp command, so the same commands work in PowerShell:

powershell
# upload a file
"put build.zip" | sftp -b - Xy12AbCd.deploy@sftp.repoforge.io

# download a file
sftp Xy12AbCd.deploy@sftp.repoforge.io:report.csv .

# use a particular key
sftp -i $HOME\.ssh\repoforge_sftp Xy12AbCd.deploy@sftp.repoforge.io

If sftp isn't found, install OpenSSH Client from Settings > System > Optional features.

GitHub Actions ​

This job builds a project and uploads the result. Create a key for the job with ssh-keygen -t ed25519 -f ci_key -N "", ask your RepoForge.io admin to add ci_key.pub to the SFTP user, then add two settings to the GitHub repository:

  • A secret called SFTP_PRIVATE_KEY containing the contents of ci_key.
  • A variable called SFTP_KNOWN_HOSTS containing the known_hosts lines from the host key fingerprints page.
yaml
name: Upload build

on:
  push:
    branches: [main]

jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build
        run: zip -r build.zip dist

      - name: Upload to RepoForge SFTP
        env:
          SFTP_PRIVATE_KEY: ${{ secrets.SFTP_PRIVATE_KEY }}
          SFTP_KNOWN_HOSTS: ${{ vars.SFTP_KNOWN_HOSTS }}
        run: |
          mkdir -p ~/.ssh
          echo "$SFTP_PRIVATE_KEY" > ~/.ssh/repoforge_sftp
          chmod 600 ~/.ssh/repoforge_sftp
          echo "$SFTP_KNOWN_HOSTS" >> ~/.ssh/known_hosts
          echo "put build.zip build-${GITHUB_SHA::7}.zip" \
            | sftp -i ~/.ssh/repoforge_sftp -b - Xy12AbCd.deploy@sftp.repoforge.io

Storing the known_hosts lines in the repository, rather than running ssh-keyscan in the job, means the job checks it's talking to the real server every time it runs.

Getting all your files out ​

Your files are yours, and SFTP is a standard protocol, so you can take a full copy at any time. An admin can create a user with Download only (or Upload and download) access and a home folder of /, which sees every file in the organisation, then run:

bash
sftp -r Xy12AbCd.admin@sftp.repoforge.io:/ ./backup

Downloads count towards your monthly download allowance. See Limits, usage and billing.

Exit codes and errors ​

sftp -b exits with a non-zero status if any command fails, so a CI job fails if an upload doesn't complete. If an upload fails part-way through, nothing is stored; run it again. Interrupted uploads can't be resumed, and writes must be sequential, which is how every common client uploads.

MessageMeaning
Permission deniedYour access doesn't allow this, for example listing a folder with upload-only access. See Users, permissions and keys.
Permission denied (publickey,password) when connectingThe username, key or password is wrong, or the login has expired.
Too many open sessions for this userThe user already has 10 sessions open.

Built with care by the RepoForge.io team.