Random Bright, Funny, Info, Deep Thoughts, AI Chats, and More

[
[
[

]
]
]

Installing an SSH server on Ubuntu is a straightforward process. The standard tool for this is OpenSSH, which provides secure remote access via the SSH protocol.
Since you mentioned you create HTML and PHP web pages, having SSH access is essential for managing your server files, configuring Apache or Nginx, and handling remote deployments.
1. Update the Package Repository
Before installing any new software, it is best practice to ensure your package list is up to date. Open your terminal and run:
sudo apt update

2. Install OpenSSH Server
Install the OpenSSH server package using the following command:
sudo apt install openssh-server

3. Verify the Installation
Once the installation is complete, the SSH service should start automatically. You can check its status with:
sudo systemctl status ssh

* If it is running, you will see “Active: active (running)”.
* If it isn’t running, you can start it manually with sudo systemctl start ssh.
4. Configure the Firewall (UFW)
If you have the Uncomplicated Firewall (UFW) enabled on your Ubuntu system, you must allow SSH traffic, or you will be locked out of remote connections.
sudo ufw allow ssh
sudo ufw enable
sudo ufw status

5. How to Connect Remotely
To connect to your Ubuntu machine from another computer, you need to know its IP address. You can find it by typing:
ip a

Once you have the IP, use the following command from your local machine (Windows PowerShell, Mac Terminal, or Linux):
ssh username@your_server_ip

> Note: Replace username with your actual Ubuntu username and your_server_ip with the address you found in the previous step.
>
Security Tip for Web Developers
Since you are working with web pages, you might eventually move to a public-facing VPS. I highly recommend disabling password authentication and using SSH Keys instead. This prevents “brute force” attacks where bots try to guess your password.
Would you like me to generate a secure sshd_config file template or show you how to set up SSH keys for your PHP development workflow?
To help secure your PHP development environment, we’ll focus on setting up SSH Keys. This is significantly more secure than a password because it uses a cryptographic pair: a private key (which stays on your computer) and a public key (which goes on the Ubuntu server).
1. Generate an SSH Key Pair
On your local computer (not the server), open your terminal or PowerShell and run:
ssh-keygen -t ed25519 -C “your_email@example.com”

* Ed25519 is the modern standard for security and performance.
* Press Enter to save it in the default location.
* (Optional) Enter a passphrase for an extra layer of security.
2. Copy the Public Key to your Ubuntu Server
You need to tell the server that your local machine is “trusted.” The easiest way is using ssh-copy-id:
ssh-copy-id username@your_server_ip

Enter your server password one last time to complete the transfer.
3. Disable Password Authentication (Hardening)
Now that you can log in with a key, you should “lock the door” so hackers can’t try to guess your password.
* Open the SSH config file:
   sudo nano /etc/ssh/sshd_config

* Find and change these lines (remove the # if they are commented out):
   * PasswordAuthentication no
   * PubkeyAuthentication yes
   * ChallengeResponseAuthentication no
* Save and exit: Press Ctrl + O, Enter, then Ctrl + X.
* Restart the SSH service:
   sudo systemctl restart ssh

4. Optimized Workflow for PHP Developers
Since you create HTML and PHP pages, you likely want to edit files directly. Here are two ways to make your life easier:
A. Use VS Code Remote SSH
If you use Visual Studio Code, install the “Remote – SSH” extension.
* It allows you to open a folder on your Ubuntu server exactly like it’s on your local machine.
* You can edit your PHP files, use the integrated terminal, and see changes live on your web server.
B. Simplify Connections with a Config File
Instead of typing ssh username@your_server_ip every time, create a config file on your local machine:
* Path: ~/.ssh/config
* Add this content:
<!– end list –>
Host myserver
    HostName your_server_ip
    User username
    IdentityFile ~/.ssh/id_ed25519

Now, you can simply type: ssh myserver
Would you like me to show you how to set up the correct file permissions for your /var/www/html folder so you can upload your PHP files via SSH without needing sudo every time?

If you didn’t see the IP address in the wall of text from the ip a command, don’t worry—it can be a bit cluttered. Since you are building web pages, you’ll need both your local (private) IP (to connect from home) and potentially your public IP (if you want to access it from outside).
Here are the cleanest ways to find them:

  1. The Simplest Command (Private IP)
    If you just want the local IP address without any extra information, use this:
    hostname -I

Why this is better: It will output only the IP addresses assigned to your machine (e.g., 192.168.1.50), making it much easier to read than the full network interface report.

  1. Finding your Public IP
    If you are hosting your PHP pages on a server (like a VPS) and need the address the rest of the world sees, use one of these:
    curl ifconfig.me

OR
wget -qO- icanhazip.com

  1. Using the GUI (If you have a Desktop)
    If you are using Ubuntu Desktop rather than the Server-only version:
  • Open Settings.
  • Click on Network (for wired) or Wi-Fi in the sidebar.
  • Click the Gear icon next to your active connection.
  • Your IP address will be listed in the window that pops up.
    Quick Reference Table
    | Need | Command |
    |—|—|
    | Local IP (Cleanest) | hostname -I |
    | Public IP | curl ifconfig.me |
    | Detailed Network Info | ip a or ip addr show |
    | Default Gateway (Router) | `ip route |
    Would you like me to show you how to set up a Static IP so your address doesn’t change every time your router reboots?

When “nothing happens” during an SSH connection, it usually means the connection is timing out. Your computer is sending a request, but the server (Ubuntu) is not responding at all, acting like a “black hole.”
Since you are setting this up for your web development (HTML/PHP), let’s troubleshoot the three most likely blockers.

  1. Identify the Error (Verbose Mode)
    Run the SSH command again, but add -v to see exactly where it stops:
    ssh -v username@your_server_ip
  • If it hangs at: Connecting to [IP] port 22… and then says Connection timed out, it’s a network/firewall issue.
  • If it says: Connection refused, the SSH service might not be running.
  1. Check the SSH Service (On the Ubuntu Machine)
    Go to your Ubuntu computer/server and verify the service is actually listening:
    sudo systemctl status ssh
  • If it says inactive or not found, run: sudo apt install openssh-server && sudo systemctl start ssh.
  1. Check the Firewalls (The Most Common Culprit)
    Even if you installed SSH, a firewall might be blocking the “door.”
    On the Ubuntu Server:
    Check if ufw is active and if it has a rule for SSH:
    sudo ufw status

If it says active but doesn’t list 22/tcp or OpenSSH, run:
sudo ufw allow ssh

On a Cloud Provider (AWS, DigitalOcean, Oracle):
If your Ubuntu machine is in the cloud, you must open Port 22 in their web dashboard (often called Security Groups or Networking Firewalls).

  1. Are you on the same network?
    If you are trying to connect to a computer in your house from a different location (like a coffee shop or a friend’s house):
  • The Problem: Your router’s firewall blocks incoming requests by default.
  • The Solution: You would need to set up Port Forwarding on your router to point external Port 22 traffic to your Ubuntu machine’s local IP.
  • Note: If you are just starting out, it’s easier to test while both computers are on the same Wi-Fi.
    Quick Diagnostic Checklist
    | Test | Command | Success Result |
    |—|—|—|
    | Ping the server | ping your_server_ip | You see “Reply from…” |
    | Check Port 22 | telnet your_server_ip 22 | Screen goes blank or shows “Connected” |
    | Check SSH Port | hostname -I | Use this to verify you have the right IP |

Termius is an excellent choice for managing your web servers because it allows you to sync your server list across your desktop and mobile phone. Since you are using Ubuntu, you have two main ways to install it.
Method 1: The Easiest Way (Snap Store)
Ubuntu comes with Snap support pre-installed. This is the fastest method:
* Open your terminal.
* Run the following command:
   sudo snap install termius-app

* Once installed, you can find it in your application menu or launch it by typing termius-app.
Method 2: Manual Installation (.deb package)
If you prefer a traditional installation or the Snap version has issues, use the official .deb package:
* Download the package:
   wget https://www.termius.com/download/linux/Termius.deb

* Install it:
   sudo dpkg -i Termius.deb

* Fix dependencies (if needed): If the command above shows errors, run:
   sudo apt install -f

> Note for Ubuntu 24.04 users: Some users have reported that the .deb version won’t open due to a “sandbox” error. If it doesn’t open, run this command to fix the permissions:
> sudo chmod 4755 /opt/Termius/chrome-sandbox
>
How to Connect to Your Server in Termius
Now that you have the tool, here is how to use it for your PHP projects:
* Create an Account: (Optional, but recommended for syncing).
* Add a New Host:
   * Label: Give it a name like “My PHP Server”.
   * Address: Enter the IP address you found earlier (using hostname -I).
   * SSH: Ensure this is toggled ON.
   * Username: Your Ubuntu username.
   * Password/Key: Use the password you set up, or better yet, import the SSH Key we created in the previous steps.
* Connect: Double-click the host, and you are in!
Bonus: SFTP for PHP Files
One of the best features of Termius for web developers is the SFTP tab. You can drag and drop your index.php or style.css files directly from your computer onto the server without using the command line.
Would you like me to walk you through how to set up an SFTP connection in Termius so you can upload your web pages easily?


Discover more from NathanLegakis.com

Subscribe to get the latest posts sent to your email.

Leave a Reply

Discover more from NathanLegakis.com

Subscribe now to keep reading and get access to the full archive.

Continue reading