There was an amateur engineer sitting at a respectable dead-end job about a decade ago. On the day he received his dismal "highest raise possible", he went ballistics -- but in a positive way with an upward career trajectory that younger engineers could use as a career growth heuristic.
His job was to write patch code and SQL scripts to maintain a large legacy financial system. He was grateful, but unfulfilled; especially considering his engineering skills weren't fully utilized and once he discovered that the difference in salary between him and a senior coworker with 15 more years of experience was about 33%. That's basically the inflation rate, compounded for fifteen years.
In other words, (1) the senior coworker hadn't had a real raise . Ever. (2) more importantly overlooked, the junior engineer, adjusted for inflation, was doing 33% worse than the senior worker was when he started.  That's why the amateur engineer went ballistic. Not through yelling and screaming, mind you; but through defying conventional thinking.
He decided to launch himself into the never never land of exponential career growth. He quadrupled his salary within a decade, then quit the corporate life and started a business. And it all started with reading more books and working on an escape plan.
One thing, he promised himself though: if the journey ever became a success, he wanted to share it with as many people as would believe him. The curse of knowledge -- not remembering what it was like to not know something -- kept that promise unfulfilled. That's why this story never came out; until a random day when a young person from a remote land asked the author:
"Can a software engineer who is not a US citizen and did not go to an American university get a job in Silicon Valley?"
The memories of living for ten years with the hopeless romance of career success hit me like a ton of bricks. I now remember exactly the questions I had as a 20-something year-old, with no job history and no credentials, living outside the US, hoping to become what I called at the time a "Technology Executive".
If you dream something strongly enough, you become it. I'm here to explain the simplest strategy that connected the dots. I'm the maintenance engineer, after going ballistics.
Yes, you can work in Silicon Valley without a US education or citizenship; that's probably the description of half the engineers working in Silicon Valley and even half the engineers starting companies.
When you're on the outside, you think about your disadvantage with the wrong mental framework. The benefit of being in the US is not some legal leg up for visa holders or some citizenship bias. It's much more helpful to think of it as Newton's law of universal job gravitation.
Newton's law of universal gravitation, and jobs
Any two bodies in the universe attract each other with a force that is directly proportional to the product of their masses and inversely proportional to the square of the distance between them.
Sir Isaac Newton
Newton had no idea that his law would someday apply to getting jobs from a distance. In other words:
Employers gravitate towards you based on their mass (company size) times your mass (your skill set); and more importantly, they get colder towards you based on the square of your distance from them.
This is because the larger an employer is, the more employee turn-over they have. So they need to be more open-minded about where they source candidates. For example, a typical large company with 100,000 employees has a 20% average turn over; i.e. it has to hire 20,000 people a year just to maintain its head-count.
At the same time, the more distant you are, the exponentially faster your distance is filled with your potential competitors. For example, think about how much more food a 16 inch pizza is vs. a 12 inch pizza, even though they're only 4 inches different in diameter. It's nearly twice as much food! By the same token, when you only slightly increase your distance from an employer, you're in effect doubling and quadrupling competition.
So if you're looking for a corporation to sponsor your legal work, you need to build up your skills, apply to the largest companies, and happen to be as close to them as possible. 
If you have hopes of working for startups someday and you're far away, the first step ironically is to aim for a large company. In space travel, to optimize for fuel costs, we leverage the orbital gravity of large objects in the same way, even if the final destination is some small moon.
I understand that this is probably difficult to execute when you're in a hurry. That's why for important decisions like this, you should be patient. Your primary quest over a long period of time investment should be to cut distance.
If you live in a different continent, your first goal should be to establish roots in the Western hemisphere, not to shoot directly for Silicon Valley. Once you've done the former, your second goal should be to move from wherever you are to California. The third goal is to move from California to anywhere in the San Francisco Bay Area. And the fourth goal should be to find opportunities in Silicon Valley. And in every step of the way, work with larger companies before you're close enough to attract small ones. 
To navigate your career to destinations beyond the horizon, follow the rules of space travel, within the realm of job opportunities.
Here's another secret: Two out of one hundred people will hear this story and say "Yes, that's going to be me." The rest will dismiss the author as a self-satisfied douche. That's probably why Silicon Valley is staying where it is for the foreseeable future, and why half of all new tech companies in Silicon Valley are started by immigrant minorities, who already believe in cutting the distance.
Build up skills.
Aim for big things.
Cut the distance in half.
Let gravity do the rest.
- If the senior engineer is making the same "real" salary as he did when he started, he hasn't gone forward. If you accept the same nominal salary as his starting salary fifteen years ago, you're really accepting a pay cut. The same nominal salary buys less Big Macs today.
- As an aside, you'll find plenty of resistance from individuals who complain that you're competing for their local jobs. This is a valid argument for non-specialized fields; but most unemployment problems at the higher tier of the specialization are structural (a mismatch of skills).
Just do a day of research to see companies starved for talent; you'll realize that the resistance is rooted in lack of skill adaptation as opposed to lack of local opportunities or too much competition. If you have the skills, you have an advantage. Don't let the nay-sayers distract you from adding your flavor of value to the world.
- I have taken exactly the formula I'm prescribing here. I afforded my US education after (not before) working in the US. The most important hack in this entire argument is to notice the word "square" in Newton's law. Let the square of distance guide your decisions.
- Immigrant Entrepreneurship Has Stalled for the First Time in Decades (due to immigration laws), Kauffman Foundation Study Shows .