Remix.run Logo
SonyShell – An effort to “SSH into my Sony DSLR”(github.com)
129 points by beligum 12 hours ago | 74 comments
underlines 3 hours ago | parent | next [-]

Reading the title, I thought: finally someone rooted/jailbroke sony cameras.

On Canon you can run Magic Lantern, an extensive mod that adds many features to Canon cameras.

Even Samsung N1 had SD Card loadable mods before they moved away from the camera market.

Rooting sony seems impossible, I never saw someone Working on it Since their Fullframe lineup launched.

ge0rg an hour ago | parent | next [-]

The last two generations of Samsung NX cameras were built around Tizen Linux, and it was (and still is) easy to get a root shell on them. They still make great photos and you still can buy them used for a good price.

NX300/NX30/NX2000 had a read-only rootfs, but for NX500 and NX1 there was a persistent mod that extended camera functionality with a menu, and you can actually SSH into them and rsync your photos... while shooting!

Background: I've recently taken over maintenance of the NX-KS mod at https://github.com/ge0rg/nx-ks-mod

kuschku an hour ago | parent | prev [-]

> Rooting sony seems impossible, I never saw someone Working on it Since their Fullframe lineup launched.

On some cameras, including the older firmwares for the current cameras, https://github.com/ma1co/Sony-PMCA-RE gives you a root shell.

beligum 12 hours ago | parent | prev | next [-]

I wanted to use my new Sony DSLR (a6700) in the same way as I use my server: by ssh'ing into it.

This is a one day hackaway helper built on Sony’s official Camera Remote SDK. It sort of mimics an ssh session by connecting to my Sony over Wi-Fi, listens for new photos or specific events... and runs scripts on them.

Thank you Sony, for not forgetting the Linux fan base. And thank you ChatGPT for freshening up my c++ skills!

SAI_Peregrinus 9 hours ago | parent | next [-]

Nitpick: that's a DSLM, or just "mirrorless" camera. There's no reflex mirror, so it's not a DSLR.

pjmlp an hour ago | parent | prev | next [-]

Some stuff that could be improved with modern C++,

Instead of

    static bool file_exists(const std::string &p) {
        struct stat st{}; return ::stat(p.c_str(), &st) == 0;
    }
      
Use the filesystem API,

    std::filesystem::exists(path);
-- https://en.cppreference.com/w/cpp/filesystem.html
beligum 42 minutes ago | parent [-]

ty!

JdeBP 5 hours ago | parent | prev [-]

I wouldn't thank ChatGPT too enthusiastically. As always for LLMs, it has given you code that is rife with common pitfalls (because, after all, they massively plagiarize sources where people post poor code).

For examples: It does not follow the Linux rules for pathname separators, but mixes in Windows-isms. It doesn't properly check whether std::atomic<bool> is actually signal safe on the target architecture. Its unique filename generation has an all-too-common failure mode. It passes by reference only to then make local value copies anyway. It does not correctly follow the XDG Base Directory Specification.

beligum an hour ago | parent [-]

Last time I hand started a c++ project was 10+ years ago so let's say it got the ball moving ;) Feel free to help cleanup a bit of my mess if you want, would love to work on this project together with others!

givemeethekeys 9 hours ago | parent | prev | next [-]

My recent research:

- Canon has a REST API, and the most affordable API supporting cameras.

- Fujifilm has an API, but not REST based, but it goes all the way back to the X-T3. Unfortunately, using it voids your warranty if there is a warranty.

- Sony has an API as well but mostly newer cameras.

- Blackmagic (video cameras) has a REST API, but their most affordable API-supporting cameras are meant for studio use, which isn't ideal for general use.

beligum 9 hours ago | parent | next [-]

I can't speak for other brands, but I started this project by digging into the LCD menu of my camera, discovering "auth", "user", "pass" and wanted to know what protocol they used to authenticate remote logins. That's when I discovered the camera just uses ssh-style auth. As a part time sysadmin, it gave me the idea to try to "log into" the camera and here we are.

varenc 4 hours ago | parent [-]

This doesn't actually use ssh at all right? By ssh-style auth you just mean a username and password? Seems to work great for the intended use case regardless !

beligum 2 hours ago | parent [-]

I'm guessing, but AFAIK, the camera runs some sort of sshd demon you log into, so I wouldn't be surprised it really does use ssh under the hood.

OptionOfT 7 hours ago | parent | prev | next [-]

> - Fujifilm has an API, but not REST based, but it goes all the way back to the X-T3. Unfortunately, using it voids your warranty if there is a warranty.

The Magnuson-Moss Warranty Act would like a word.

dtgriscom 8 hours ago | parent | prev | next [-]

I read the first item as:

> ... and (the most affordable API) supporting cameras

when it was (probably?) meant as:

> ... and the most affordable (API supporting cameras)

Spastche 9 hours ago | parent | prev | next [-]

any info about Nikon?

jiggawatts 6 hours ago | parent [-]

Nikon hasn't yet figured out how WiFi works, let alone a REST API!

They're firmly stuck in the early 1990s in terms of system software.

danhau 2 hours ago | parent [-]

It seems most of the newer cameras (Z6 iii, Z5 ii, Z50 ii) and the Z9 support „Wi-Fi STA“ mode, as Nikon calls it. All other models apparently only do „AP“ mode, where the camera turns into an access point - super annoying.

Curiously the Z8 (which is basically a Z9) and the Zf (which is basically a Z6 iii) don’t support STA.

jiggawatts an hour ago | parent [-]

AP mode ought to be faster and more reliable because the camera sends the signal directly to the receiving device instead of an external AP rebroadcasting it and halving the available bandwidth.

The problem is with the software. It disconnects and sends data incredibly slowly, orders of magnitude slower than what the hardware is capable of.

speed_spread 8 hours ago | parent | prev [-]

My Pentax KS-2 (2015) has a REST API.

https://sourceforge.net/p/pentaxks2wifiremote/wiki/K-S2%20We...

geerlingguy 2 hours ago | parent | prev | next [-]

Neat project, the one thing I still don't understand is how it's still so hard to wirelessly get photos on and off professional/prosumer cameras.

We had EyeFi cards back in the day, and I could configure them to (flakily, but given enough time, it worked) automatically upload RAW image files to a local FTP server while I was out shooting an event.

Years later, and a bunch of janky apps that mostly work with low-res JPEGs or if you fiddle with them, maybe RAW files, are the best that Canon, Nikon, and Sony have to offer first-party :(

matrss 36 minutes ago | parent | next [-]

My Sony a7iii can definitely upload to FTP by itself, JPEG and RAW. That is my primary means of getting images off of it. I would have appreciated if it did WebDAV though, then I could make it push to Nextcloud directly...

beligum an hour ago | parent | prev [-]

Believe it or not, but I'm old enough to have used Eye-Fi cards back in the day and its shitty performance inspired me to hack away on this project in the first place!

baobun 10 hours ago | parent | prev | next [-]

Aside if author is around: You may want to rename it to not include "Sony" in the name. If the project gets popular and catches their eye it might become a headache.

Suggestions: DShelLR, dshr, dslr-sh, camshell

CrispyKerosene 5 hours ago | parent | next [-]

Sony doesnt make DSLR cameras, there is no 'reflex mirror'. These are mirrorless cameras, or Interchangeable Lens Cameras E-Mount (ICLE) as sony calls them

beligum 10 hours ago | parent | prev | next [-]

It's late, but still up. Thanks for the heads up ;)

beligum 9 hours ago | parent [-]

Done!

dtgriscom 8 hours ago | parent [-]

Nice: https://github.com/goudvuur/sonyshell now automatically redirects to https://github.com/goudvuur/sonshell . (Didn't know you could do that.)

typpilol 6 hours ago | parent [-]

Did you have to set it up? Or automatic when you rename?

underlines 3 hours ago | parent [-]

that's a feature of github when renaming repos

yjftsjthsd-h 9 hours ago | parent | prev | next [-]

Legal reasons aside, it'd be nice if it eventually expands in scope to not be tied to original hardware. Eg. Kodi, nee XBMC, doesn't even mostly run on XBoxes anymore.

metadat 10 hours ago | parent | prev [-]

Can it be "Sny" or "Slony" (Simpsons nod)? Keep a fragment in, please, for discoverabilities sake!

adzm 9 hours ago | parent | next [-]

I know a genuine Magnetbox, Panaphonic, and Sorny when I see one.

NewJazz 10 hours ago | parent | prev [-]

Just list the devices it has been tested with in the readme.

jiffage13 3 hours ago | parent | prev | next [-]

Excited to see this develop.

Sony quietly removed the PAL/NTSC switch on some recent FX3/J1 firmwares — a really user-hostile move for anyone trying to avoid lighting flicker or needing flexible frame rates. The only practical “fix” I see in the wild is paying grey-market sellers (using leaked service tools I presume) to flip the 'region blob' so the menu comes back.

Is sonshell likely to be a useful vector for a more freely available solution? Not sure what level of access it actually offers i.e. is firmware/policy blobs readable/manipulable, and can persistent changes be made?

beligum 2 hours ago | parent [-]

I'm afraid the only thing I do is use the official SDK to wirelessly log in to the camera. No firmware hacking at all. That said, if the SDK offers a setting the LCD menu on the camera doesn't, it would be fairly trivial to change it, yes.

SoftTalker 7 hours ago | parent | prev | next [-]

When I read the first word of the title I immediately thought this was going to be about a new rootkit.

beligum 2 hours ago | parent [-]

Sorry to disappoint you ;)

josephg 3 hours ago | parent | prev | next [-]

Nice work! I've wanted something like this while shooting, since people want to see what the photos I'm taking look like and all the software I've tried seems kinda bad.

Does this work better than the built-in FTP client software in the cameras? I've been tempted to just run an FTP server on my ipad which automatically shows all uploaded photos.

beligum 2 hours ago | parent [-]

Funny you ask, since the a6700 doesn't have ftp support and it mainly was the reason I started this app in the first place. Also, wiring into the command structure with little shell callbacks offers me a LOT more flexibility than initially thought.

0xffany 2 hours ago | parent | prev | next [-]

Why change the title from Sony camera to Sony DSLR when the repository is specifically targeting Sony mirrorless cameras, not DSLRs...

beligum 2 hours ago | parent [-]

The app was built to suit my needs with my Sony a6700 but it uses the official SDK. So it should theoretically support all the cameras the SDK supports.

arghwhat 6 minutes ago | parent [-]

The SDK does not support any DSLR's, and Sony announced its last DSLR camera 10 years ago.

ladyanita22 an hour ago | parent | prev | next [-]

Didn't know these run Linux

HardwareLust 12 hours ago | parent | prev | next [-]

Can you control the camera via script/CLI? Things like releasing the shutter, focus, apeture, etc?

beligum 11 hours ago | parent [-]

It's not implemented yet, but fairly easy to add, yes.

beligum 9 hours ago | parent [-]

Already patched this in, I'll test it tomorrow :)

StrangeDoctor 7 hours ago | parent | prev | next [-]

Very interesting project, I wish I had gone down this route instead of the undocumented hell of usb PTP with hundreds of edge/corner case work arounds.

SchemaLoad 4 hours ago | parent | next [-]

It is surprising that after all these years, there is still no good way to transfer files between two devices over USB. MTP exists but it was never widely supported and it seems like even the support it did have is slowly rotting as the answer became just connect everything to cloud storage.

lights0123 4 hours ago | parent [-]

reMarkable tablets end up exposing a USB ethernet device with a /23 private subnet and listing an IP address to visit in a browser. It works much more reliably than it should.

jauntywundrkind 6 hours ago | parent | prev [-]

The fact that USB ptp is some baseline is kind of exceedingly great, even if yeah in practice it'a a huge mess of vendor extensions tacked on. I like trying to have some collaboration & specs! It's a monster oh sure but gphoto2 probably wouldn't have come about, as a sick compendium of all camera backs & vendor extensions, if there wasn't a common thread, common binding for cameras! Once you go from USB to IP you're (generally) untethered unmoored from anything shared!

What's done here is super admirable & super neat. But it's even more spelunking into the unknown than USB ptp imo! Thankfully there's some pretty old school direct on-the-line protocols that are kinda just working!

It's interesting to me at least to navel gaze over. The attempt to have common tools versus the just doing whatever.

One of my favorite connectivity solutions ever was the Nvidia Shield Controller (2015). A wifi (wifi direct/wifi-p2p at that!) video gaming controller. With audio that uses ozproto's stack, a usb-over-ip setup! Something about just tunneling USB being conceptually easier to reason about & do than deciding what IP services to make for a controller is so elegant and neat and weird. https://github.com/devmapal/nvidia-shield-controller-driver

ge0rg an hour ago | parent [-]

When reverse-engineering some of the Samsung NX camera firmware files, I found USB-PTP code that implements different custom remote commands <https://chaos.social/@ge0rg/114723076401717110> but I'm not deep enough into PTP to make sense of them.

Is there anywhere a group focusing on understanding and re-implementing custom PTP protocols?

mschuster91 2 hours ago | parent | prev | next [-]

Heh, looks like the old OpenMemories hack [1] might actually have a successor now for modern cameras?

The old Sony lineup actually didn't just have a Linux kernel to run its base operating system, they actually included a bastardized Android layer on top of that so people could develop apps - but it died out pretty soon, so Sony removed it after the Mark 2 models and with it went the entrypoint for rooting.

[1] https://github.com/ma1co/OpenMemories-Framework/blob/master/...

g-mork 8 hours ago | parent | prev | next [-]

the A7R has a background FTP function but the problem is Wifi is deadly unreliable and low bandwidth for transferring huge files. for camera automation I've found it much easier to write to SD card then handle import in batches

dave8088 5 hours ago | parent [-]

Multi thousand dollar pro camera and they can’t figure out the WiFi. Sony’s unwillingness to provide any material firmware updates is so disappointing.

Etheryte 3 hours ago | parent [-]

Unfortunately it isn't just Sony, every Canon I've ever owned has had trash wifi. It must be one of those teams in an org that's an afterthought of an afterthought.

k33n 3 hours ago | parent | prev | next [-]

So... if you have guests on your network or are otherwise connected to a network with lots of people on it, can they just grab all your photos this way?

beligum 2 hours ago | parent [-]

As of now, yes, but luckily auth support is on my todo list SOON ;)

constantcrying 10 hours ago | parent | prev [-]

My trust in a project which can not identify the most important characteristic of the hardware used is pretty low.

The A6700 is not, in any way, a DSLR camera.

astrange 9 hours ago | parent | next [-]

People think all professional cameras are called "SLRs".

A rangefinder is a higher quality camera than an SLR ever was and a full frame mirrorless probably has better quality than a DSLR, in both cases because it's easier to design lenses for them. A medium format camera can be better than all of those.

tecleandor 2 hours ago | parent | next [-]

A medium format camera can also be a DSLR. An a6700 or an A7 is not a rangefinder, it's a mirrorless camera. You're mixing up characteristics.

DSLR means: it's digital, it uses one lens, and the visor image comes from the same lens that goes to the film, but reflected on a mirror to your eye (probably through a pentaprism, but that can vary), so you can see the same image that will be captured in the sensor.

A rangefinder is a camera where you look... through a rangefinder. It's a visor independent of the film/sensor, like a classic Leica. That means that the image you see is not exactly the same that will reach the sensor/film, as it will go through a different optical system. There are digital rangefinders like the M series Leicas.

Mirrorless means, it doesn't have a mirror to send the image to the visor. The typical mirrorless cameras nowadays get the visor image directly from the sensor, you don't look through a rangefinder. A rangefinder is mirrorless, but not every mirrorless is a rangefinder. Most digital mirrorless cameras aren't rangefinders.

A rangefinder (or mirrorless) camera is not inherently better than a DSLR. Mirrorless cameras can have simpler optical designs that achieve more quality easier, but there are better and worse cameras in both sides.

CrispyKerosene 5 hours ago | parent | prev [-]

Respectfully, its not that simple. I dont think you know what you are talking about.

exidy 4 hours ago | parent | next [-]

I think it's better to steelman rather than assert ignorance on the part of the person you're replying to.

It is true that people these days associate the DSLR form-factor with professional photography, despite the heavy use of rangefingers by those such as Robert Capa etc not that long ago. And it is also true that both rangefinders and mirrorless ILCs avoid the need for retrofocus designs which in theory should make for higher-quality lenses at the same weight, or similar quality and a lower weight.

As for "better" this is often a matter of preference and it's okay for people to have different preferences. For me personally, I wish there was more experimentation in ILC form factor, it seems most (with a few notable exceptions) ape the pentaprism hump even if they don't contain one.

Etheryte 3 hours ago | parent | prev [-]

I think it's easy to see what they mean, even if you don't agree with them. I think it puts too much emphasis on glass as there's so much more that goes into getting a shot. I do pick up my old film cameras every now and then for enjoyment, but if I have to get a shot, I'm always taking the newest thing I have. It's hard to beat multiple stops of stabilization in the lens and the body along with the black magic of modern sensors.

fooker 8 hours ago | parent | prev | next [-]

Not having a mirror is not the most important characteristic of the hardware for this project.

Being able to control it through an API is. What happens after you trigger the shutter is out of scope. Speaking of shutter buttons, a bunch of new cameras don’t have shutters but the button is still called a shutter button.

miladyincontrol 7 hours ago | parent | next [-]

While I mostly agree its a matter of jargon, the original author never calls their camera a DSLR.

Also yes while yes many cameras do not have moving shutters, they still operate with an electronic shutter which just like a moving one does have various limitations.

I'd argue though to many a photographer, calling any ILC or sufficiently costly camera a DSLR is akin to a post calling an android phone a linux phone. To the layperson the nuance between ubuntu's kernel or a pixel's doesnt matter to them, however to the intended audiences it sure does.

hilsdev 7 hours ago | parent | next [-]

To be pedantic for the people still reading this, curious enough to go further without falling down a Wikipedia rabbit hole.

The reflex mirror in a (D)SLR directs the image up through the viewfinder prism to the eyepiece. This mirror flips upwards just before the shutter opens. This mechanic action has a decent bit of inertia and can cause blurring in some extreme cases.

Mirrorless refers to digital cameras where the sensor operates the digital viewfinder, so like an SLR “you get what you see”. For rangefinders and TLRs, your view is offset from the picture lens, so if you’re really trying to nail a composition and not “fix it in post” SLRs and mirrorless offer an advantage, which is part of why they became so predominant.

crtasm 7 hours ago | parent | prev [-]

The repo originally said DSLR in the readme+description.

beligum an hour ago | parent [-]

This is correct. I have ironed out my silly mistake just minutes after seeing comments of smarter people showing me the light.

rs186 5 hours ago | parent | prev [-]

No. When I see a6700 and DSLR used in the same sentence, I have to question whether that is a misunderstanding on the author's side, whether it's actually for Sony a6700 or some other camera, or if anything in the repo makes sense or if the author knows what they are doing. This erodes confidence if the author cannot even get the very basics right.

beligum an hour ago | parent [-]

It's probably laziness AND misunderstanding on the author's side ;)

beligum 10 hours ago | parent | prev | next [-]

You are correct.

pastel8739 5 hours ago | parent | prev [-]

DLSR stands for Digital Single-Lens Reflex. An a6700 is indeed digital, has a single lens, and is undoubtedly a camera. All it’s missing is a reflex mechanism. So I’d say that in four out of five ways, it is indeed a DSLR camera.

josephg 3 hours ago | parent [-]

Sometimes four out of five doesn't cut it. Thats like claiming my car is an electric car because "they both have batteries and motors". Or like saying C is a functional programming language because its a programming language that "has functions".

The defining characteristic of SLR and DSLR cameras is the reflex mechanism, which is a giant mechanism inside the camera that sits in front of the film or sensor. The mechanism uses a mirror to allow the viewfinder to work. And the whole thing needs to physically flip out of the way when you press the shutter button to expose the film. But as a result, SLR / DSLR cameras are usually way bigger physically to make room for the mirror and the reflex mechanism.

Mirrorless cameras like the A6700 don't have this reflex mechanism, so they're not DSLR cameras. They're called mirrorless cameras. Same as the cameras in our phones.