Recently, I’ve started building an API which should serve as my personal API. The project is hosted on Github, and you might take a look if you want. It’s connected tightly to this blog and one of the features that I wanted to implement first, was to provide links for my linklog. You can read the entire story in the previous post. The stack I have there is pretty simple:
- Fly.io for hosting
- Sinatra (Ruby) for the API
I’ll cut it short: at some point I needed to send a file from my computer to the server hosting my application. It wasn’t that straightforward, so I decided to write a post about it and help others who might be in the same situation.
Here’s what you need to exchange files between your computer and the server:
Disclaimer: I’m using MacOS, so the commands might be different on other systems.
Assumptions: you have a Fly.io account and you have a project deployed. You also have a
flytcl command available in the terminal
flyctl wireguard create– this will create a Wireguard configuration file for you. If you don’t have Wireguard installed, you can download it from here. Use the generated configuration file to connect to the Wireguard server.
fly ssh issue– this will generate a new SSH key for you. You can use it to connect to your server. Save it somewhere, e.g.
tmp/flycert, you’ll need it later.
- Get address of your app:
flyctl ips private– this will give you the address of your app. You can use it to connect to your server.
scp -i tmp/flycert LOCAL_SOURCE root@\[ADDRESS\]:REMOTE_DESTINATION– this will copy the file from your computer to the server. You can use it to upload files to your server. Escaping the address is important –
That’s it! You can use the same command to download files from your server. Just change the order of the arguments.