15

I am running Ubuntu Server 18.04, and I was wondering if it was possible to download mega.nz files from the command-line, e.g. using putty or some other tool?

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Jye R.
  • 183
  • 1
  • 1
  • 5
  • 5
    Why would you need putty for that? And no: putty is a desktop tool for connecting to a server and has nothing to do with the ability to download files from another server. Have a look at the commands `wget` and `curl`. Both accept URLs as a download method. – Rinzwind Nov 15 '19 at 09:00
  • @Rinzwind I have same question for my centos server! There is no ordinary way to download files from mega.nz website because they are using very specific file sharing links that only work on their wesite in web browser! you should click at link from their own site to download! – Mojtaba Rezaeian Jan 04 '21 at 07:33

4 Answers4

14

Megatools allow you to copy individual files as well as entire directory trees to and from the cloud. You can also perform streaming downloads for example to preview videos and audio files, without needing to download the entire file first. Megatools are robust and optimized for fast operation - as fast as Mega servers allow. This is quite fast. Memory requirements and CPU utilization are kept at minimum.

Megatools is provided in Ubuntu by the universe repository. You can install megatools in all currently supported versions of Ubuntu with the following command:

sudo apt install megatools
karel
  • 110,292
  • 102
  • 269
  • 299
  • 1
    Its too complicated to use, also it adds many unwanted commands on linux and none of them is megatools, no help to find list of those added commands and thats crazy for complicating a simple job!! also it requires to enter email and password to sign in. I just want to download a file from their site from link and without signing in. – Mojtaba Rezaeian Jan 04 '21 at 07:39
  • @MojtabaRezaeian It's possible to download a file from MEGA from a link without signing in to MEGA, but this only works if you already have the link. MEGA website only supports searching for files for users who have signed in. – karel Jan 04 '21 at 07:43
  • I have the link, this is the file: [https://mega.nz/file/CLR1FDhY#l6Kts2vytSoSnDAWQMrpnn-KNVfkJM5S2vVs9YPITwk] – Mojtaba Rezaeian Jan 04 '21 at 07:46
  • The movie is visible on that link.. also it have a download button under movie on same page and its working in my windows firefox without requiring me to sign in. But same link not working on linux with wget and not even after installing megatools and using command megadl. thats wiered. – Mojtaba Rezaeian Jan 04 '21 at 07:53
  • I also tried to open that page with lynx command! no chance! seems their site is pretty secured! that seems a very specific kind of security platform. – Mojtaba Rezaeian Jan 04 '21 at 08:00
  • `megadl` works, but considering [this issue](https://github.com/megous/megatools/issues/157) the URL must be adapted. So your URL would need to be changed, like this: `megadl 'https://mega.co.nz/#!CLR1FDhY!l6Kts2vytSoSnDAWQMrpnn-KNVfkJM5S2vVs9YPITwk'`, tested here and it's working. – João Ciocca Nov 30 '21 at 18:12
8

As of November/21, Ubuntu 20.04 and megatools 1.10.2, you can use Megatools as mentioned in @karel's answer, but megadl has an unfixed issue while dealing with MEGA URLs.

If you need to download a file, the URL will be something like https://mega.nz/file/<some_id>#<some_other_id> and needs to be changed into https://mega.co.nz/#!<some_id>!<some_other_id> for it to work. Remember to put between single quotes, so:

megadl 'https://mega.co.nz/#!<some_id>!<some_other_id>'

Folder URLs need to be adapted too, from https://mega.nz/folder/<some_id>#<some_other_id> to https://mega.co.nz/#F!<some_id>!<some_other_id>, so:

megadl 'https://mega.co.nz/#F!<some_id>!<some_other_id>'
João Ciocca
  • 181
  • 1
  • 4
  • `strLink="https://mega.nz/folder/ExdyETia#m0FwgdqrHmfnS4Xakn_rMg/file/R00wWJYZ";megadl "$(echo "$strLink" |sed -r -e 's"mega.nz"mega.co.nz"' -e "s'#'!'g" -e 's"/folder/"/#F!"' -e 's"/file/"!"')"` (the link is for lineageos btw) but I think this link is not downloading (despite accepting the link now) because it is in an encrypted folder see https://github.com/megous/megatools/issues/254. I will try to compile the latest from that github. – Aquarius Power Jun 01 '22 at 05:47
  • It seems that the bug was resolved now, as far as I can see from the bug tracker. – Valerio Bozz Jan 22 '23 at 17:13
  • The issue was already marked as closed back when I wrote this answer. You can see people as recently as Jan 21 https://github.com/megous/megatools/issues/157#issuecomment-1013698756 claiming the workaround is needed and works as expected. I haven't touched in this recently, so I can neither confirm nor deny it's been fixed. – João Ciocca Jan 22 '23 at 18:37
2

megacmd works without login

mega-get "https://mega.nz/file/bFdkyJhK#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

have fun building this on debian : P

"proper" distros like nixos or arch have a package for megacmd ...

but you can use nix on debian : D

sudo apt install nix nix-setup-systemd
nix-channel --add https://nixos.org/channels/nixpkgs-unstable
nix-channel update
export PATH=$PATH:$HOME/.nix-profile/bin

nix-env --install megacmd
mega-get ...
milahu
  • 297
  • 2
  • 8
-1

I solved this making a .sh file with 600 lines that look like this:

megadl 'https://mega.nz/xxxxxxxxxxxxxxxxxxxxxxxxx'

You hace to download megatools previously. Give to your .sh file execution permissions (chmod +x fileName) and launch it into your command line (./fileName.sh)