SSH to Our Server#
You may start to understand why people sometimes throw up their hands and use an “easier” provider like Vercel or Heroku. Those providers configure all the same things we’ve done so far, then sell it to you at a (steep) markup.
But if you can handle the basics on your own (and you can), you’ll save money and have more control over your infrastructure.
Seriously, some folks are happy to chew through C code full of malloc, calloc, and int *int_list_ptr = (int *)struct_list_of_ints;, but adding a route is too hard? Not you; onward and upward.
Here’s a review of the networking flow for us to SSH into our server:
- Our computer communicates with the server’s public Elastic IP address.
- The server is in a public subnet with a route to the internet gateway.
- The security group allows inbound traffic on
22/tcpfrom our public IP address. - Our SSH private key matches the public key we uploaded to AWS.
how connect aws wm with ssh#
Cost check: No new resources in this lesson. You’re using the EC2 instance and Elastic IP you already have; cost remains ~$7.60/mo for the instance plus ~$3.60/mo for the EIP.
SSH into patientping-web and update its message of the day.
- Log into the AWS Console and grab the public IP address of your server:
- Navigate to “EC2” → “Instances.”
- Select the
patientping-webinstance and copy its “Public IPv4 address.”
- Make sure you can at least reach the server on
22/tcpfrom your computer. I prefer to usenc(short fornetcat):
nc -zv YOUR.INSTANCE.IP.ADDR 22
# Connection to YOUR.INSTANCE.IP.ADDR port 22 [tcp/ssh] succeeded!- Add an entry to your local SSH config, to serve as a shortcut for connecting to
patientping-web. This is not only convenient; it will also allow our CLI tests to verify the connection.
- Open your
~/.ssh/configfile in your text editor of choice. If it doesn’t exist, create it first:touch ~/.ssh/config - Add the following
Hostentry, setting the IP address and the absolute path of your private key as appropriate:
Host patientping
HostName IP_ADDR # burada aslinda sanal makinamiza atadigimiz elstic ip(ipv4) giriyoruz
User ec2-user # amazon user ismi genelde bu idk why
IdentityFile ~/.ssh/patientping-key- Save your changes to the config file.
- Test your configuration by running
ssh patientping; it should log you in fully (because you didn’t set a password on your private key). - While on the EC2 instance, update the “Message of the Day” (a simple welcome message that prints whenever someone logs into the server) to say
Welcome, PatientPing Server Admin!:
echo 'Welcome, PatientPing Server Admin!' | sudo tee /etc/motd > /dev/null- Verify the
motdis working by logging out of the server and back in.
exit
ssh patientping