Connect remotely by ssh for ubuntu devices server - GitMasterNikanjam/C_WiKi GitHub Wiki

To use SSH to connect from a Windows PC to a Ubuntu PC, you can follow these steps:

1- Install an SSH client on Windows: There are several SSH clients available for Windows, such as PuTTY, MobaXterm, or Windows Subsystem for Linux (WSL) if you prefer a more integrated approach.
2- Install SSH server on Ubuntu: If the SSH server is not already installed on the Ubuntu PC, you can install it by running the following command in the terminal:

sudo apt-get install openssh-server

3- Find the IP address of the Ubuntu PC: You'll need to know the IP address of the Ubuntu PC to connect to it. You can find this by running ifconfig or ip addr show in the terminal on the Ubuntu PC.
4- Connect from Windows to Ubuntu using SSH client: Open your SSH client on Windows and enter the IP address of the Ubuntu PC. If you're using PuTTY, for example, enter the IP address in the "Host Name" field, leave the port as 22 (default for SSH), and click "Open". If it's your first time connecting, you may be prompted to accept the SSH key of the Ubuntu PC.
5- Enter credentials: Once connected, you'll be prompted to enter your username and password for the Ubuntu PC.
6- Explore and use Ubuntu from Windows: Once authenticated, you'll have command-line access to the Ubuntu PC from your Windows machine. You can execute commands, transfer files using SCP, or perform any other tasks you need.
Remember to keep your SSH connections secure by using strong passwords or, ideally, SSH keys for authentication. Also, be cautious about opening SSH ports on your firewall and only allow connections from trusted IP addresses if possible.


avahi-daemon is a service on Linux systems that facilitates local network service discovery via the mDNS/DNS-SD protocols. It allows devices on the same local network to discover each other without needing a central DNS server. Here's how it works and its relevance to SSH communication on Ubuntu:

Key Features of avahi-daemon:

  1. Service Discovery: It enables applications to discover services such as SSH, HTTP, and others on the local network automatically. This means you can connect to devices by their hostname rather than their IP address.

  2. mDNS (Multicast DNS): avahi-daemon uses mDNS, which allows for name resolution within the local network without requiring a traditional DNS server. When a device joins the network, it advertises its hostname and services.

  3. DNS-SD (DNS Service Discovery): Along with mDNS, DNS-SD provides a way to browse and locate services on the network. Applications can list available services (like SSH) without needing to know their IP addresses.

How to Use avahi-daemon for SSH Communication:

  1. Installation: If avahi-daemon is not already installed, you can install it using:

    sudo apt update
    sudo apt install avahi-daemon
    
  2. Starting the Service: Ensure the avahi-daemon service is running:

    sudo systemctl start avahi-daemon
    sudo systemctl enable avahi-daemon
    
  3. Connecting via SSH: Once avahi-daemon is running, you can connect to other devices on the same network using their hostnames followed by .local. For example, if your Ubuntu device has a hostname of mydevice, you can SSH into it with:

    ssh [email protected]
    

    Replace user with the appropriate username on the target device.

Benefits of Using avahi-daemon for SSH:

  • Convenience: You can connect to devices without needing to remember or look up IP addresses, making it easier to manage multiple devices.

  • Dynamic IP Handling: If a device's IP address changes (common with DHCP), you can still connect using its hostname.

  • Zero Configuration Networking: It simplifies networking in environments where configuring DNS is impractical.

Troubleshooting:

  • Firewall Settings: Ensure that your firewall allows mDNS traffic (UDP port 5353). You can use ufw to allow this:

    sudo ufw allow from 224.0.0.0/4 to any port 5353 proto udp
    
  • Service Status: Check the status of avahi-daemon if you encounter issues:

    sudo systemctl status avahi-daemon
    
  • Network Issues: Ensure that all devices are on the same local network and subnet for mDNS to function correctly.

Using avahi-daemon can significantly enhance the usability of SSH and other network services in a local environment.