This topic has been covered many times on this forum. Try doing a search next time.
You need to be a legal resident to enlist in the US military. The MOSes and assignments you can hold will be limited until you gain your citizenship.
To be an officer, you must be a US citizen.