Sample code for 30+ languages & platforms
Swift

SFTP SymLink - Create Symbolic Link on Server

See more SFTP Examples

Demonstrates how to create a symbolic link on the SFTP server.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let sftp = CkoSFtp()!

    // Pass a domain or IP address..
    success = sftp.connect(hostname: "my-sftp-server.com", port: 22)
    if success == true {
        success = sftp.authenticatePw(login: "mySFtpLogin", password: "mySFtpPassword")
    }

    if success == true {
        success = sftp.initializeSftp()
    }

    if success != true {
        print("\(sftp.lastErrorText!)")
        return
    }

    // Create a symbolic link on the server.
    // We'll create a link in our HOME directory named "sshd_config"
    // which points to the file /etc/ssh/sshd_config.
    success = sftp.symLink(oldPath: "/etc/ssh/sshd_config", newPath: "sshd_config")
    if success != true {
        print("\(sftp.lastErrorText!)")
        return
    }

    print("Successfully created symbolic link.")

}