This article will serve as a walkthrough to connect to a MaxCDN Push Zone using your preferred SFTP client.
To connect to a Push Zone please follow these steps:
Upload to a Push Zone
- Open your preferred SFTP client, and use the following credentials:
- HOSTNAME = ftp.zone.alias.netdna-cdn.com (example: ftp.foo.bar.netdna-cdn.com)
- USERNAME = zone.alias (example: foo.bar)
- PORT = 22
- Navigate into the folder labeled public_html.
- Upload your files into this folder.
For new file uploads, it can take up to 24 hours for your file to be accessible from all locations.
Custom Upload Scripts
Python - Using pysftp
-
Install pysftp:
$ sudo pip install pysftp
-
Create Upload Script:
# Example local file to upload remote_file = 'test.txt' srv = pysftp.Connection(host="ftp.ZONE.ALIAS.netdna-cdn.com", username="ZONE.ALIAS", password="your_ftp_password") srv.put(remote_file, '/public_html/' + remote_file) srv.close()
Ruby - Using net-sftp
-
Install net-sftp:
$ sudo gem install net-sftp
-
Create Upload Script:
require 'net/sftp' Net::SFTP.start('ftp.ZONE.ALIAS.netdna-cdn.com', 'ZONE.ALIAS', :password => 'your_ftp_password') do |sftp| sftp.upload!("test.txt", "/public_html/test.txt") end
PHP - Using sudo libssh2-php
-
Install libssh2-php:
$ sudo apt-get install libssh2-php
-
Create Upload Script:
<?php $server = 'ftp.ZONE.ALIAS.netdna-cdn.com'; $port = '22'; $username = 'ZONE.ALIAS'; $passwd = 'your_ftp_password'; $connection = ssh2_connect($server, $port); if (ssh2_auth_password($connection, $username, $passwd)) { $sftp = ssh2_sftp($connection); echo "Connection status: OK. Uploading file!"."n"; $file = 'test.txt'; $contents = file_get_contents($file); file_put_contents("ssh2.sftp://{$sftp}/public_html/{$file}", $contents); } else { echo "Nope! Can not connect to server!"."n"; } ?>
We hope this article was helpful and as always, If there are any questions or concerns about any of the topics mentioned in this article, please feel free to reach out to support - we are available 24/7 by chat or email.