iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🙆‍♀️

Troubleshooting Initial SSH Connection Issues on Ubuntu Server

に公開

Hello,

I am currently working on building a cluster environment and performing cluster computing, so I am setting up the environment using Raspberry Pis.

First, I wanted to enable SSH communication between the Raspberry Pis, but I hit a stumbling block right away. I am recording the method I used to solve it here.

Until I hit the wall

Raspberry Pi cluster configuration

In this Raspberry Pi cluster, I designated one Raspberry Pi as the Master (the commander) and the other two as Workers (the calculators).

pi0: Master

↓ Do the heavy lifting!

pi1: Worker1
pi2: Worker2

Therefore, I want to operate the other two Raspberry Pis from Raspberry Pi 0.

Unable to perform SSH communication

Since I want to SSH using key authentication in the cluster, I planned to proceed with the following steps:

  1. Connect the Raspberry Pis via LAN cables (using a switch)
  2. Assign static IP addresses to the Ethernet
  3. Verify communication with ping
  4. SSH via password
  5. Share keys

However, I got stuck at step 4. The password-based authentication would not proceed.

When performing password-based authentication via SSH, settings on the receiving end (the Worker side in this case) are required, and PasswordAuthentication must be enabled.

Most likely, it is set to "no" or commented out by default.
You need to set it to "yes" or uncomment it.

terminal (Worker)
sudo vi /etc/ssh/sshd_config
/etc/ssh/sshd_config
PasswordAuthentication yes
terminal (Worker)
sudo systemctl restart ssh   # Apply the settings 

However, this setting alone was apparently insufficient, and even after trying the following, it would not proceed to the exchange for logging in (like asking to enter a password).

terminal (Master)
ssh-copy-id ubuntu@[Worker's IP]
Permission denied (Pubkey)

I was stuck here for a long time.

Solution

How to fix it

It seems there was one more required setting in sshd_config:

terminal (Worker)
sudo vi /etc/ssh/sshd_config
/etc/ssh/sshd_config
KbdInteractiveAuthentication yes

This setting was necessary.

terminal (Worker)
sudo sshd -t   # If nothing is displayed, it is OK
sudo systemctl restart ssh   # Don't forget to apply the settings

Explanation and verification

This enables "interactive" logins, which include password entry. Because this was not set, the SSH attempt was rejected without even being asked for a password.

Also, this command is used to check for any typos or configuration errors in the SSH configuration file (sshd_config):

terminal (Worker)
sudo sshd -t

Sometimes you might see a warning like the one below, but Gemini told me it's safe to ignore (not really an explanation, but still).

missing privilage separation directory: /run/sshd...

Once you have copied the keys to the Worker and confirmed you can SSH, you no longer need the password, so you should set the following back to "no".

/etc/ssh/sshd_config (Worker)
PasswordAuthentication no
KbdInteractiveAuthentication no

Done!

Once my Raspberry Pi cluster project reaches a milestone, I'd like to write an article summarizing the whole thing.
Until then, I plan to write quick notes like this whenever I run into trouble.

Discussion