Copying Files From Remote Machine
29 February, 2024 - Tags: copying, baremetal
Today, I'm going to write about how to copy files to and fro from the remote system. More than copying files, this is part of my daily workflow and I want to write about it.
I've a baremetal machine running in hetzner and I use that machine for compiling a lot of stuff reason being it's fast there and I can do anything on it.
The two primary thing I use the machine these days are for compiling programs and packaging things for wolfi repo.
When I end up compiling and I get a static binary (well mostly) and then I want to use that binary on my host system. I need to copy the same from remote system to host one. Let's take an example of lazygit. I clone lazygit in my baremetal home directory and then built it. Now, here's how I copy it to my laptop.
$ rsync -avz --progress bm:~/lazygit/lazygit .
receiving incremental file list
lazygit
27,832,796 100% 1005.42kB/s 0:00:27 (xfr#1, to-chk=0/1)
sent 43 bytes received 10,575,913 bytes 325,414.03 bytes/sec
total size is 27,832,796 speedup is 2.63
I use rsync mainly but the same can be done by scp
command as well.
When I need to build a package for wolfi repo then I create a melange config locally on my laptop and transfer it to the baremetal machine. This is done using the following command:
$ rsync -av ~/os/kubeadm-bootstrap-controller.yaml bm:~/os/
The syntax looks weird in the starting but if you look at it carefully then it's similar to the cp
command. The only difference is that when the source or destination is a baremetal machine then we append the name of the machine before the filename. In this example, the name of the machine is bm
. You can also use user@ip:
if don't have the machine named in your ~/.ssh/config
file.
So, I think the main learning for the day was that I don't need to google the syntax for rsync or scp command, It's intuitive.