Downloading and uploading using scp

Under Linux using the following command in shell it is possible to download all files from the router:

scp -r -p -P 22 username@192.168.88.1:/ .

Beware: there is a dot (.) at the end, meaning to save “here”, ie. in current dir.
It saves the files usually in a new subdirectory named “pckg” (or “disk” ?)

BUT: is it possible to download (and upload) just a single file when the filename is known, ie. w/o using the -r switch (for recursive)?
My tests unfortunately failed. :frowning:

And uploading isn’t working in RouterOS 6.47.10 (it stalls), and seems to crash (?) the RouterOS as it throws out a logged in WebFig user.

One can of course create files on the router by doing export in CLI:

/ export file=my-export-all
/ip export file=my-export-ip-section-only

The files get the extension .rsc. They can be seen by this in CLI:

/file print

It is possible to scp single file … just don’t include the leading / on path to sorce file name. Example:

scp username@router:flash/skins/default.json .

Essentially it’s exactly the same as shown by /file/print.

And copying files to router works the same way … without leading / in the destination path.

Thx.
Can you give an example for a new file on the router that was created by you? Ie. then which directory path to specifiy?

I was using these commands:

scp user@router:usb1-part1/log.5.txt .
scp log.5.txt user@router:flash/

My router has USB stick plugged in (it’s mounted under /usb1-part1) and I have logging configured to store files there. The first command fetched one of older log files to linux PC. The second command copied the same file back to router, this time into /flash/ directory (my router has 16MB flash, so storage root us RAM disk and fkash is mounted under /flash/). So I ended up having two copies of that file:

user@router] /file> print
Columns: NAME, TYPE, SIZE, CREATION-TIME
 #  NAME                             TYPE        SIZE       CREATION-TIME
 0  usb1-part1                       disk                   2023-06-06 18:00:01
 1  usb1-part1/lost+found            directory              2018-09-08 18:46:43
[.... snip ....]
 5  usb1-part1/log.5.txt             .txt file   67.4KiB    2023-05-28 17:05:51
[.... snip ....]
18  flash/log.5.txt                  .txt file   67.4KiB    2023-10-23 14:46:22
19  flash                            disk                   2023-10-23 14:46:21
20  flash/skins                      directory              2023-06-03 09:33:47
21  flash/skins/default.json         .json file  34         2023-06-03 09:35:38
[user@router] /file>

If you want to scp file into router’s storage root snd you want to keep file name, then omit the remote file path entirely so that command ends at the colon sign, e.g. scp file.txt user@router:

@mkx, your setup is really interesting.
I too would like to attach a USB stick. How to configure it in RouterOS?
And how did you create a RAMdisk in RouterOS?

I still cannot upload any file via scp (it stalls, I’ve to do CTRL-C to abort scp).
Upload and download via WebFig is ok, but I need it in shell (terminal) using scp.

https://wiki.mikrotik.com/wiki/Manual:System/File

Warning: If device has a directory named “flash” in its file list, then files which you want to be kept after system reboot/power cycle must be stored within it. As anything outside of it is kept within a RAM disk and will be lost upon reboot. Note: this does not include .npk upgrade files as they will be applied by upgrade process before system discards the RAM drive content.

you may not have this folder

scp -P 22 user@router:/log.0.txt .
I don’t see any problems

The scp server in RouterOS lacks also wildcards in filenames.