I want to convert some old android phones(2017+) into SSH only servers, is it possible?
Sure, Android is an operating system based on the Linux kernel, and you can run any user land on that. In fact, your average free alternative app store (e.g. fdroid) will have e.g. debian containers to execute.
run the phones 24/7 without a battery
Many phones' hardware won't boot without a battery. But you can definitely find phones that do.
I don't want to use anything besides the motherboard and the wifi(or if possible to get internet from USB), and scrap display, battery, camera and other sensors for money
your scrapping parts operation will have an expected negative return, forget about that. The cost of removing a screen doesn't justify the price you'll get for a used screen. What do you think a brightness sensor or an accelerometer costs from the manufacturer? We're talking cents here.
bare metal performance, no android junk inside that eats cpu and ram
Android is your operating system. This is like "I want to drive my car with bare metal performance, no motor control junk"… Android will very likely be necessary to get your phone into an operational state where you can execute anything that needs networking. So, forget about that too.
root access, just like in a server
You will need to have a phone that you can get root access to (many phones have a developer mode that you can enter more or less easily, by far not all) to do any of this.
The scope of my project is being able to reuse old phones as linux servers and run stuff like nginx, posgresql, nodejs, ruby. And even docker if possible.
Docker is the least of your problem – Linux namespaces work and are an important part of modern Android.
The rest makes absolutely no sense at all.
- nginx is a web server, but you've got a device that's only attached via wifi – whatever offers that wifi connection could just as well run that web server, and you could throw away your phone.
- postgresql is a database server. You'll find that a phone's storage is the opposite of what you want for a database server.
- nodejs: hm, that is a classically rather RAM-intense thing. You sure you want your old phone to run nodejs?
- Ruby: Well, that's just a popular scripting language. There's probably many android apps written in it. There's no reason this is any special.
In case you want to develop this into some kind of business: You're inventing slow, very power hungry, unreliable, expensive servers. A single ARM or x86_64 server box can host hundreds of virtual machines that would be more capable than what you could put up with the same number of phones. At a fraction of the hardware cost, at a fraction of the power consumption (mobile processors are not optimized for server workloads, and hundred USB supplies are less efficient than one ATX supply), and at way better maintainability. With the option to get server firmware updates.
I'll give you something to ponder: In Germany, electrical power is 0,34€ per kWh. That means 1W is ca 3€ over a year. A USB power supply (5V) offering 750 mA outputs 3.75 W. Typical power efficiency of these isn't very high – 80% would be good, so that's 4.7 W on the input side to run your phone at low load. That's 14€ a year.
For comparison: a small VM at azure, ionos, AWS or digital ocean costs about 24€ a year. That includes power, the hardware to run on, traffic cost, an IP address (which really dominates the price here - if you can home many servers behind the same IPv4 address, you get away much cheaper), the whole frigging data center with 24/7 staffing, cooling, multiply-redundant storage clusters powering your system... No way you can buy a used phone and operate it for long enough to even come close to that price.
is it possible?
almost always has ayes
answer, so the question does not really have any value ... what is your specific question about the project?