One line. One command. The whole "DevOps" of a small trading setup, explained the slow way.
You want a restaurant in another city to cook the same dishes. You don't fly there every time you tweak a recipe โ you drop the updated recipe at the post office, and the restaurant picks up its mail.
The whole one-line command โ ssh lightsail 'cd ~/ExecutionProject && git pull --ff-only' โ in plain English:
"Hey restaurant, go check your mailbox for new recipes."
You're not sending the recipe through this command. You're telling the restaurant to fetch it.
ssh lightsail 'cd ~/ExecutionProject && git pull --ff-only'
ssh
lightsail
'cd ~/ExecutionProject'
'git pull --ff-only'
The && between #3 and #4 just means "do this, and if it works, do that next."
In one breath: "Phone the restaurant, walk to the kitchen, check the mailbox for new recipes."
--ff-only? (the "no surprises" flag)Picture this: you have a recipe book at home, the restaurant has the same recipe book. You both add page 50. Different page 50s. Now what?
--ff-onlyGit tries to glue both versions together. Usually messy, sometimes silently wrong. You don't notice until someone cooks the wrong dish โ i.e., a trade goes wrong three days later.
--ff-onlyGit refuses. It says "wait โ the books don't match, I'm not going to guess." You see the error immediately and decide what to do.
Rule of thumb: loud failure is a feature, not a bug. You always want to know now if something's weird โ not three days later, when real money is on the line.
On your laptop, file ~/.ssh/config stores the nickname โ address mapping. This is your phone's contact list.
Without this: every command is ssh -i ~/.ssh/lightsail-trading ubuntu@13.202.219.68 '...'. Like dialling the full number every time.
On the server, day one only:
After this, the server folder knows which GitHub repo it belongs to. Every future git pull just refreshes from that same source.
The server needs permission to read from GitHub โ either the repo is public, or a "deploy key" / token is set up.
Set up once. Reuse forever. That's the whole bargain of "infrastructure" โ pay an hour now to save five minutes every day.
SSH security works like a fancy lock-and-key set. The private key stays on your laptop โ never share it. The public key is the lock โ paste it on as many servers as you want. Stolen public key = harmless. Leaked private key = disaster.
~/.ssh/lightsail-tradinglightsail-trading.pub# 1. Make the key pair $ ssh-keygen -t ed25519 -f ~/.ssh/lightsail-trading Creates two files: the private key, and ".pub" โ the lock. # 2. Put the lock on the server $ ssh-copy-id -i ~/.ssh/lightsail-trading.pub ubuntu@13.202.219.68 (Or paste it into the Lightsail console when creating the instance.) # 3. Save the server as a contact โ edit ~/.ssh/config Host lightsail HostName 13.202.219.68 User ubuntu IdentityFile ~/.ssh/lightsail-trading # 4. Lock down the private key (mandatory) $ chmod 600 ~/.ssh/lightsail-trading SSH refuses to use a private key that others on the laptop can read. # 5. Test it $ ssh lightsail โ If it logs you in without asking for a password, the lock and key are working.
The server can now let you in. But the server itself still can't read from GitHub. The server needs its own key โ a different identity from you โ registered with GitHub.
# 1. SSH into the server (everything below runs there, not your laptop) $ ssh lightsail # 2. Make a key pair *for the server* $ ssh-keygen -t ed25519 -C "lightsail-trading" Press Enter through prompts to accept defaults. # 3. Show the server's public key โ copy the whole output $ cat ~/.ssh/id_ed25519.pub ssh-ed25519 AAAAC3Nz... lightsail-trading # 4. In your BROWSER: GitHub repo โ Settings โ Deploy keys โ Add deploy key Title: "Lightsail trading server" Key: (paste the output from step 3) Allow write access: โ leave unchecked (server only needs to read) โ Add key # 5. Clone the repo (note the git@github.com: prefix โ that uses the key) $ git clone git@github.com:your-user/your-repo.git ~/ExecutionProject # 6. Test it $ cd ~/ExecutionProject && git pull โ "Already up to date." with no password prompt = live connection.
From this point on, every future git pull โ including the one-line deploy from your laptop โ just works.
# 1. ON YOUR LAPTOP โ save the change locally $ git add . $ git commit -m "what you changed" # 2. SEND IT TO THE POST OFFICE (GitHub) $ git push # 3. TELL THE RESTAURANT TO CHECK ITS MAIL $ ssh lightsail 'cd ~/ExecutionProject && git pull --ff-only' # 4. (Only if you changed requirements.txt โ new ingredients) $ ssh lightsail 'cd ~/ExecutionProject && source venv/bin/activate && pip install -r requirements.txt' # 5. Restart whatever is running, so it picks up the new code
Skipping step 2 is the most common mistake. The restaurant checks its mail, finds nothing new, and you wonder why nothing changed.
And what they actually mean.
git push. The server pulls from GitHub, not your laptop. If the post office never got the letter, the restaurant can't pick it up.chmod 600 ~/.ssh/lightsail-trading. That tells the OS "this key is private to me." SSH refuses to use keys other people on your computer could read.git status, look at what's different, decide whether to keep or throw away those changes.You don't need to log in, look around, and type commands one at a time. Once the plumbing is set up, a single line from your laptop deploys code to a machine running in a data centre on the other side of the city.
Most "infrastructure" work is exactly this: spend an hour once, save five minutes a day, forever.