Ctrl K

SSH into a Local Network Device

Connect from a Linux host to another device on the same local network over SSH, using a named host alias in ~/.ssh/config.

Connect from a Linux machine to another device on the same local network. In this case we will use a headless Ubuntu box whose IP is already known as the device to connect. Simply using an alias registry in ~/.ssh/config lets you connect with a short command instead of the full user and IP.

Check existing SSH hosts

If the file does not exist, create it and set permissions. SSH ignores config and key files that are too open.

mkdir -p ~/.ssh
touch ~/.ssh/config
chmod 700 ~/.ssh
chmod 600 ~/.ssh/config

Add the host to ~/.ssh/config

Open ~/.ssh/config and append the block below. Replace 192.168.1.5 with the target device IP and your user with the Linux username on that device. No extra file is needed for password login or the default SSH key.

nano ~/.ssh/config
Host local-ubuntu
    HostName 192.168.1.6
    User your-user

Connect

Once saved, connect using the alias.

ssh local-ubuntu

The equivalent direct command without an alias:

ssh myuser@192.168.1.5

On the first connection, SSH asks whether to trust the host fingerprint. Type yes if the IP and device are correct. If the target is configured for password login, the password prompt will show up.

Copy

After connection, move files when needed with scp command. Copy all files in a driectory with * or copy a specific file by filename.

scp -r $USER@192.168.1.5:/home/$USER/myproject/* ~/projects/myproject/

File Sizes

Check file/folder sizes whenever needed in this process with du command.

du -sh /path/to/folder

Debug failed connections

Run SSH with verbose output to see where a failed connection breaks down.

ssh -v local-ubuntu

If ssh reports 'No route to host', confirm basic reachability from the host machine and verify the target IP from the target machine itself.

# From the host
ping 192.168.1.5

# From the target device
ip addr

If the target device is reachable on the network but SSH fails to connect, confirm the SSH server is installed and running on the target.

# On the target Ubuntu device
sudo systemctl status ssh

# If not installed
sudo apt update
sudo apt install openssh-server
sudo systemctl enable --now ssh