SCP File from local to Heroku Server

13,196

Solution 1

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

Solution 2

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 .

Solution 3

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
Share:
13,196

Related videos on Youtube

user2738206
Author by

user2738206

Updated on July 12, 2022

Comments

  • user2738206
    user2738206 almost 2 years

    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 [email protected] format for heroku.

    I've tried running 'heroku run bash'

    scp  /home/user/app/config.yml
    

    I'm not sure how I can get it in the

    scp [email protected]:/home/user/dir1/file.txt [email protected]:/home/user/dir2' 
    

    format

  • Tyler Graf
    Tyler Graf over 8 years
    user@mylocalmachine - do I need an ip address? How do I tell it where my local machine is?
  • Michael
    Michael almost 7 years
    Really upload config files unencrypted?
  • Andre Miras
    Andre Miras almost 7 years
    @Michael, yes you can use gpg if you want, but that was not the OP question and I tried to keep it straightforward. Feel free to add a complement answer to this one if you think it's useful.
  • Gunnar
    Gunnar almost 7 years
    Neat trick, really useful for what I was looking for. Thanks.
  • Endogen
    Endogen over 6 years
    "mylocalmachine" is the IP and "user" is the user that you are logging in to your server
  • niklasae
    niklasae about 6 years
    If you want to encrypt it you can upload it using: cat <file_name> | gpg -ac -o- | curl -X PUT -T "-" https://transfer.sh/<file_name>.gpg And download it using: curl https://transfer.sh/<hash>/<file_name>.gpg | gpg -o- > <file_name>
  • Tri
    Tri over 4 years
    Is this safe I upload my .env file to transfer.sh ..?
  • Andre Miras
    Andre Miras over 4 years
    Depends what you mean by safe @GofyandKitty, but you can always encrypt it
  • Roel
    Roel about 4 years
    How do i put user@mylocalmachine using my laptop local machine? :D
  • Zuabi
    Zuabi almost 4 years
    transfer.sh does not seem to work right now. file.io seems to be an alternative
  • Ged Flod
    Ged Flod about 2 years
    Google : Get my IP copy your IP and replace mylocalmiachine by this IP , user by your laptop username
  • Ged Flod
    Ged Flod about 2 years
    By i got kex_exchange_identification: Connection closed by remote host ERROR