Documentation » Using WinSCP » Guides » Cloud Computing »

Injecting SFTP or FTP URL to a page (Amazon EC2 management console)

If you are managing a large amount of servers, it may not be feasible for you to save a site for each of them in WinSCP. If your management portal offers an SFTP or FTP URL for each server, you can simply click it, as WinSCP registers to handle the URLs. But if such URL is not available, as is a case with Amazon EC2 management console, you may end up copying the host name from management portal to WinSCP all the time.

Instead, you may use a user script, that automatically converts the host name on the management portal into a clickable URL.


A user script is a JavaScript code that is automatically run for a selected pages and can modify the page according to user’s needs.

Example for Amazon EC2 Management Console

Following functional example injects “Open in WinSCP” and “Open in PuTTY”1 links next to Public DNS field on Instances page of Amazon EC2 management console.

The user script is available for download: WinSCP_SFTP_URL_for_Amazon_EC2.user.js.

To install the script, install a user script manager to your browser and click on the download link above.

// ==UserScript==
// @name        WinSCP and PuTTY links for Amazon EC2
// @namespace
// @author      WinSCP
// @homepage
// @description Adds an "Open in WinSCP" link next to "Public DNS" field on Instances page of Amazon EC2 management console
// @include     https://**
// @icon
// @version     2.0
// @grant       none
// @require
// ==/UserScript==
    function () { waitForHostNameElements (); },
function waitForHostNameElements()
    var targetNodes = $('span:contains("Public DNS:")');
    if (targetNodes && targetNodes.length > 0) {
        targetNodes.each ( function () {
            // link not added yet
            if ($(this).html().indexOf('sftp://') < 1) {
                // Retrieve hostname
                var hostname = $(this).text().replace("Public DNS:", "").trim();
                // Ignore terminated instances
                if (hostname != "-") {
                    // Change the username if needed
                    var username = "ec2-user";
                    var uri = '://' + username + '@' + hostname + '/';
                        ' &ndash; <a href="sftp' + uri + '">Open in WinSCP</a>' +
                        ' &ndash; <a href="ssh' + uri + '">Open in PuTTY</a>');
        } );


  1. For “Open in PuTTY” link to work, you still need WinSCP installed, as WinSCP handles the ssh:// URL.Back
  2. While Google Chrome supports user scripts on its own, it does not support @require directive, nor it runs scripts not available in Chrome Web Store.Back

Last modified: by martin