Skip to content

Instantly share code, notes, and snippets.

@stevecrozz
Last active September 25, 2024 23:31
Show Gist options
  • Select an option

  • Save stevecrozz/c1538df807c03881503ebc0eff7e3ce4 to your computer and use it in GitHub Desktop.

Select an option

Save stevecrozz/c1538df807c03881503ebc0eff7e3ce4 to your computer and use it in GitHub Desktop.
Copy a file to remote heroku dyno

If you ever want to copy a local file to a remote heroku dyno, you can! Steps:

  1. Execute heroku ps:exec with the --ssh arg to connect to a dyno of your choice (and reveal the native ssh connection parameters). For example heroku ps:exec --app=my-app --dyno=web.1 --ssh
  2. Find the ssh command that was used using ps. For example ps ax | grep ssh | grep heroku-exec-key
  3. Pipe your file right into that ssh command, receive it with cat on the other end and redirect it wherever you want. For example: cat myawesomefile | ssh -o UserKnownHostsFile=/var/folders/fs/v_kjxw8s1nl1lcd9lm_r1vs80000gq/T/heroku-exec-proxy-key2024825-1652-7r5vmz.q7vch -o ServerAliveInterval=10 -o ServerAliveCountMax=3 -p 80 -i /var/folders/fs/v_kjxw8s1nl1lcd9lm_r1vs80000gq/T/heroku-exec-key2024825-1652-4trc3k.akeov c953c40bb7caa54d4@heroku-exec-proxy.herokuapp.com "cat > /tmp/myawesomefile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment