This guide will walk you through setting up SSH on your Ubuntu iMac and then connecting to it seamlessly using your latest iMac.


Prerequisites:

  1. Two iMacs:
    • Your latest iMac (running macOS - this will be your client machine).
    • Your 2012 iMac with Ubuntu 24.04 LTS successfully installed and running (this will be your server machine).
  2. Network Connection: Both iMacs must be connected to the same local network (via Ethernet or Wi-Fi).
  3. Basic Terminal Familiarity: Knowing how to open a terminal and run basic commands on both macOS and Ubuntu.


Step 1: Prepare the Ubuntu Server (2012 iMac)

First, we need to ensure the SSH server software is installed and running on your Ubuntu machine.

  1. Open the Terminal: On your Ubuntu 2012 iMac, open the Terminal application.
  2. Update Package Lists: It's always a good idea to update before installing new software.
    Bash
    sudo apt update
    
    Enter your password when prompted.
  3. Install OpenSSH Server: If it's not already installed, install the SSH server package.
    Bash
    sudo apt install openssh-server
    
    Type Y and press Enter if prompted to confirm the installation.
  4. Check SSH Server Status: Verify that the SSH service is running.
    Bash
    sudo systemctl status ssh
    
    You should see output indicating active (running). Press q to exit the status view.
  5. Find Your Server's IP Address: You'll need this address to connect from your client machine.
    Bash
    ip addr show
    
    Look for the network interface name (commonly eth0 for wired or wlan0 for wireless) and find the inet address. This is your local IP address (e.g., 192.168.1.100). Note this down.

Your Ubuntu server is now ready to accept SSH connections.


Step 2: Connect from Your macOS Client (Latest iMac)

Now, switch over to your modern iMac and initiate an SSH connection to the Ubuntu server.

  1. Open the Terminal: On your latest iMac, open the Terminal application (Applications > Utilities > Terminal).
  2. Attempt the SSH Connection: Use the ssh command followed by your Ubuntu username and the server's IP address you noted in the previous step.
    Bash
    ssh your_ubuntu_username@your_ubuntu_server_ip
    
    Replace your_ubuntu_username with your actual username on the Ubuntu machine and your_ubuntu_server_ip with the IP address you found.
  3. Handle the First Connection: The first time you connect, you'll see a message about the host's authenticity and be asked if you want to continue.
    The authenticity of host 'your_ubuntu_server_ip (your_ubuntu_server_ip)' can't be established.
    ...
    Are you sure you want to continue connecting (yes/no/[fingerprint])?
    
    Type yes and press Enter. This adds the server's fingerprint to your known hosts list, so you won't be asked again unless the fingerprint changes (which could indicate a security issue).
  4. Enter Your Password: You will be prompted for your password on the Ubuntu machine.
    your_ubuntu_username@your_ubuntu_server_ip's password:
    
    Type your password and press Enter. Note that the characters won't appear as you type.

If successful, you will see the command prompt of your Ubuntu machine. You are now remotely connected! You can run commands directly on the server. Type exit to close the SSH connection.


Step 3: (Optional but Recommended) Set Up SSH Key-Based Authentication

Typing your password every time can be tedious, and key-based authentication is generally more secure.

  1. Generate SSH Keys (on macOS Client): If you don't already have SSH keys on your latest iMac, generate them.
    Bash
    ssh-keygen -t rsa -b 4096
    
    Press Enter for the default location (~/.ssh/id_rsa). You can optionally set a passphrase for extra security (recommended), or leave it blank for no passphrase.
  2. Copy Public Key to Ubuntu Server (from macOS Client): This command copies your public key (id_rsa.pub) to the server and adds it to the authorized_keys file, allowing key-based logins.
    Bash
    ssh-copy-id your_ubuntu_username@your_ubuntu_server_ip
    
    You will be prompted for your Ubuntu password one last time. After this, it will copy the key.
  3. Test Key-Based Login (from macOS Client): Try connecting again using the ssh command from Step 2.
    Bash
    ssh your_ubuntu_username@your_ubuntu_server_ip
    
    This time, you should log in without being asked for a password (unless you set a passphrase, in which case you'll be asked for that).


Troubleshooting Tips:

  • Firewall: Ensure the firewall on your Ubuntu server (if active) allows incoming connections on port 22 (the default SSH port). sudo ufw allow ssh is a common command for this with ufw.
  • Incorrect IP: Double-check the IP address you are using. It should be the local network IP (e.g., 192.168.x.x or 10.0.x.x).
  • SSH Service: Verify the SSH server is running (sudo systemctl status ssh).
  • Username/Password: Ensure you are using the correct username and password for your Ubuntu account.
  • Key Permissions: If using key-based auth, ensure permissions on .ssh folder (chmod 700 ~/.ssh) and authorized_keys file (chmod 600 ~/.ssh/authorized_keys) on the server are correct.


Conclusion

You've successfully transformed your older iMac into a powerful, accessible development machine running Ubuntu 24.04. By setting up SSH you can now code, build, and manage projects on it directly from the comfort of your latest macOS machine. This not only gives your older hardware a new lease on life but also provides a flexible and efficient remote development environment.