SCP File from local to Heroku Server

后端 未结 5 577
温柔的废话
温柔的废话 2021-02-07 08:41

I\'d like to copy my config.yml file from my local django app directory to my heroku server, but I\'m not sure how to get the user@host.com format for heroku.

I\'ve tri

相关标签:
5条回答
  • 2021-02-07 08:57

    As @tamas7 said it's firewalled, but your local machine is probably also firewalled. So unless you have a private server with SSH accessible from the Internet, you won't be able to scp.

    I'm personally using transfer.sh free and open source service.

    Upload your config.yml to it:

    $ curl --upload-file ./config.yml https://transfer.sh/
    https://transfer.sh/66nb8/config.yml
    

    Then download it back from wherever you want:

    $ wget https://transfer.sh/66nb8/config.yml
    
    0 讨论(0)
  • 2021-02-07 08:58

    Expanding on tamas7's answer:

    You can connect to your computer from the heroku server.

    If your computer is behind a router, you'll also need to forward the connection to your computer.

    1. You computer must accept ssh connections

    On my mac it was as simple as enabling it in the Preferences / Sharing panel.

    2. Your router needs to forward the connection to your computer.

    Go to your router's settings page in your browser (typically 192.168.0.1 but varies depending on the router). Find the port forwarding section and forward some port to your computer on port 22.

    This is how it looked on my tp-link:

    Here I am making sure that port 22000 is forwarded to my computer (192.168.0.110) on port 22.

    3. Find your external IP

    Simply google "what is my IP".

    4. Scp your file from heroku

    heroku run bash
    scp -P 22000 your_user@your_external_IP:/path/to/your/file .
    

    5. Undo everything!

    Once you're done it's probably good practice to disable the port forwarding and remote login.

    0 讨论(0)
  • 2021-02-07 09:01

    If you need to download your entire repo, for example to recover an app that you no longer have locally, use heroku git:clone -a myapp. Docs.

    0 讨论(0)
  • 2021-02-07 09:09

    According to http://www.evans.io/posts/heroku-survival-guide/ incoming connections are firewalled off. In this case you need to approach your local machine from the Heroku server.

    heroku run bash
    scp user@mylocalmachine:/home/user/dir/file.txt .
    
    0 讨论(0)
  • 2021-02-07 09:15

    This is a bit late to answer this question, but I use services like localtunnel - https://localtunnel.github.io/www/ to copy files from local machine to heroku.

    First, run a python HTTP server in the directory where the file is located.

    cd /path/to/file
    python3 -m http.server
    

    This starts a server in port 8000. Configure localtunnel to connect to that port.

    lt -s mylocal -p 8000
    

    Now from your heroku machine, you can fetch the file via curl.

    curl -XGET http://mylocal.localtunnel.me/myfile.txt > myfile.txt
    
    0 讨论(0)
提交回复
热议问题