This is definitely legal. I did the same thing about 6 months ago - purchased a triplex with an FHA loan with 3.5% down, and I live in one unit while using the other two as short-term rentals. The two major roadblocks I'd think about (which it sounds like you already are) are 1) financing and 2) validating short-term and long-term rates for the area.
1) Financing - FHA loans on multi-family properties can sometimes cause some headaches that you need to be aware of. For example, FHA requires that each of the units must have separate electric meters. Additionally, although you don't technically need separate water meters, the water lines must at minimum have separate shut-offs for each unit (i.e. it cannot be one water line with only one shut-off). These are two specific issues that I ran into, but generally speaking, FHA loans are maybe a bit more strict/nuanced than some other loan products, so you'll want to do your homework on the property ahead of time to ensure it will meet FHA requirements - or at least have the ability to be remedied to meet the FHA's requirements prior to closing.
2) STR vs. LTR Rates - as mentioned above, as part of evaluating the validity of an investment like this, you'll want to "underwrite" the deal. This includes mapping out everything from income, expenses, vacancies, etc. to understand every single dollar that "comes in" and "goes out" of the investment. Keep in mind the additional costs typically associated with short-term rentals - cleaning fees, supplies, furnishings, utilities, any short-term license fees in your local market, etc. You want to do this to ensure that the time and money investments of operating a short-term rental outweigh that of a long-term rental. If you figure out through your underwriting that operating an STR only nets you $100 more per month compared to an LTR, but you're spending 20 extra hours a month to do so, does it make more sense to simply do an LTR? Make sure the juice is worth the squeeze...
Another factor to consider when weighing LTR vs. STR: most lenders will not qualify STR income until you have two years of tax returns showing that STR income, whereas an LTR can qualify either 1) rent in place if occupied or 2) the market rent. So if you're trying to scale your investment portfolio rapidly within the next two years, do not plan on being able to use your STR income to do so for your debt-to-income qualification purposes.