Swan Chain
  • BULDERS
    • Getting Started
    • DApp Developer
      • Deploying Your First Smart Contract with Remix
      • Interacting with Smart Contract on Swan Chain Using Go
    • App Developer
      • Building Docker Images and Deployment file with LDL
        • Lagrange Definition Language(LDL)
      • Deploying with Swan SDK
      • Store and Retrieve a File with Swan Storage
        • 1. Set up the python-MCS-SDK
        • 2.Create and Manage Buckets
        • 3.Upload Files and Folders
        • 4.Retrieve and Download Files
        • 5.Delete Files and Buckets
    • Node Operator
      • Swan Node Snapshots
    • Market Provider
      • Storage Market
      • AI/ML Orchestrator
        • Decentralized AI Marketplace
        • Connect to Orchestrator
      • Web3 ZK Computing Market
        • ZK Auction Engine
        • Sequencer
        • Contribute zk-UBI-task
          • How to Contribute
        • Example
      • Customized Market Provider
    • Computing Provider
      • Fog Computing Provider(FCP)
        • FCP Setup
        • Migrating FCP to Swan Mainnet
        • FCP Funding Operations Guide
        • FCP FAQ
      • Edge Computing Provider (ECP)
        • ECP Setup
        • ECP Funding Operations Guide
        • ECP FAQ
      • FAQ
    • Storage Provider
      • Storage Auction System
    • Developer Tools
      • Swan SDK
        • Python Swan SDK
          • Special Case: Create ssh login instance
          • SWAN Orchestrator SDK - Function and Parameter Reference
        • Go Swan SDK
          • A Sample Tutorial
      • Swan Console
        • Getting Started
        • Blockchain GPU Task Example
        • Custom Blockchain GPU Task Pools
      • Lagrange
      • Swan IPFS Storage
      • Nebula Block Cloud
      • Ecosystem Projects
    • Mission 3.0
      • Get Started
        • For Users
        • For Space Holders
  • NETWORK REFERENCE
    • Network Info
      • Set Up Your Wallet
      • Bridge Token
    • Contract Addresses
    • Fees
  • Core Concepts
    • Introduction to Swan Chain
    • Consensus Layer
    • Peer-to-peer (P2P) Network
    • Payment Channels
    • Service Discovery
    • Market Provider
      • Storage Market
      • AI Computing Marketplace
        • Orchestrator
        • Auction Engine
        • Bidding Task State Machine
      • ZK Proof Marketplace
        • ZK Task
        • ZK Pool
    • Storage Layer
    • Computing Layer
      • Computing Provider Protocol
      • Computing Provider Account
      • Layer3 Computing Protocol
      • Reputation System
      • Dynamic Pricing
    • CDN Layer
    • Tokenomics
      • UBI Allocation Curve
      • Computing Provider Income
      • Computing Provider Collateral
        • Collateral Requirement and Computing Unit
        • DePIN Oracle
      • Governance
        • Treasure DAO
    • Glossary
  • Swan Chain Campaign
    • Swan CP UBI
    • Swan Chain Mainnet
      • Network Information
      • Swan Token
      • Swan Chain Mission
        • Social Mission
        • Onchain Mission
        • Mission: Celestial Bloom
      • Swan Provider Campaign
        • Fog Computing Provider (FCP)
        • Edge Computing Provider (ECP)
        • Market Provider (MP)
      • GALXE Campaign
      • Free Tier and Special Credit Programs
    • Atom Accelerator Race
      • Before You Get Started
        • Set Up MetaMask
        • Claim SepoliaETH
        • Claim testSWAN
      • CP Acceleration Program
      • Builder Acceleration Program
      • On-chain Interaction Race
      • Community Engagement Challenge
      • FAQ
    • Swan Saturn Testnet
      • Before You Get Started
        • Set Up MetaMask
        • Claim Faucet Tokens
        • Bridge Tokens
      • Transaction Drive Program
      • Community and Educational Events
      • Partnership and Integration Program
      • KOL Program
      • Computing Provider Program
        • FAQ
      • Developer Grant Program
      • FAQ
    • Swan Jupiter Testnet
      • How to Participate
      • Before You Get Started
      • Network Early Adopter
      • FAQ
  • RESOURCE
    • Links
    • Brand Kit
Powered by GitBook
On this page
  • SSH repo
  • Deploy SSH Application with Swan SDK
  1. BULDERS
  2. Developer Tools
  3. Swan SDK
  4. Python Swan SDK

Special Case: Create ssh login instance

SSH repo

  1. fork GitHub repo: https://github.com/sonic-chain/sdk-demo

  2. On your local computer, generate ssh key with ssh-keygen -t rsa -b 4096

  3. Copy the public key as the value of sshkey in deploy.yaml

version: "2.0"
type: node-port
services:
  vm:
    image: filswan/ubuntu-ssh-user:22.04
    env:
      - sshkey=<YOUR-LOCAL-SSH-KEY>
      - username=swantouser
    expose:
      - port: 22
      - port: 30002
      - port: 30003
      - port: 30004
      - port: 30005
      - port: 30006
      - port: 30007
deployment:
  vm:
    lagrange:
      count: 1
  1. Push modification to your GitHub repo

Deploy SSH Application with Swan SDK

  1. Choose a computing provider who can support SSH application

import json
import swan

swan_orchestrator = swan.resource(api_key='<SWAN_API_KEY>', service_name='Orchestrator')

available_instances = swan_orchestrator.get_instance_resources()
print(available_instances)

In the output of available resources list, choose a cp_account_address in ssh_ready list of the instance type you want (such as C1ae.small):

[InstanceResource({
  "hardware_id": 0,
  "instance_type": "C1ae.small",
  "description": "CPU only \u00b7 2 vCPU \u00b7 2 GiB",
  "type": "CPU",
  "region": [
    "Virginia-US",
    "Quebec-CA",
    "Jakarta-ID",
    "Kowloon City-HK",
    "North Rhine-Westphalia-DE",
    "Seoul-KR",
    "Eastern-HK",
    "Ivano-Frankivsk Oblast-UA",
    "Kowloon-HK",
    "Saxony-DE",
    "Jiangsu-CN",
    "Tokyo-JP",
    "Kuala Lumpur-MY",
    "North West-SG",
    "Central and Western District-HK",
    "Central and Western-HK",
    "National Capital Territory of Delhi-IN",
    "Florida-US"
  ],
  "price": "0.48",
  "status": "available",
  "snapshot_id": 1732047600,
  "expiry_time": 1732048445,
  "ssh_ready": [
    {
      "cp_account_address": "0xEf675CA43Ce25b2594079caCE98C7362733E1F5B",
      "region": "Quebec-CA"
    },
    {
      "cp_account_address": "0x4cbe96669516961Ebaf7225Fe07a34d56c4B2B12",
      "region": "North West-SG"
    },
    {
      "cp_account_address": "0x34378963383667F87b5C185A7b716c2C353EF9d2",
      "region": "Florida-US"
    }
  ]
  1. Deploy SSH application with the selected CP

Deploy the SSH application to use that cp_account_address, put it in the preferred_cp_list.

result = swan_orchestrator.create_task(
    repo_uri='<YOUR-GITHUB-REPO-URI-FOR-SSH>',
    wallet_address='<WALLET_ADDRESS>',
    private_key='<PRIVATE_KEY>',
    instance_type='<INSTANCE_TYPE>', #such as 'C1ae.small',
    preferred_cp_list=['SSH-READY-CP-ACCOUNT-ADDRESS']
)
task_uuid = result['task_uuid']
# Get task deployment info
task_deployment_info = swan_orchestrator.get_deployment_info(task_uuid=task_uuid)
print(json.dumps(task_deployment_info.to_dict(), indent=2))

Please wait for awhile to get the SSH command by

app_urls = swan_orchestrator.get_real_url(task_uuid)

If everything goes well, you will get SSH command result like this:

['ssh root@38.80.81.17 -p30001']

Then you can run this command in your shell. You will see something like the following output:

 _
| |
| |     __ _  __ _ _ __ __ _ _ __   __ _  ___
| |    / _` |/ _` | '__/ _` | '_ \ / _` |/ _ \
| |___| (_| | (_| | | | (_| | | | | (_| |  __/
|______\__,_|\__, |_|  \__,_|_| |_|\__, |\___|
              __/ |                 __/ |
             |___/                 |___/
Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.4.0-174-generic x86_64)

 * Documentation:  https://docs.lagrangedao.org
 * Support:        https://discord.com/invite/8vaB6rKSAu

This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, you can run the 'unminimize' command.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@sdk-demo-e5tv:~#
PreviousPython Swan SDKNextSWAN Orchestrator SDK - Function and Parameter Reference

Last updated 7 months ago