0

I’m working on Hadoop multi node cluster, so nodes communicate using SSH here is my problem:

  • I have 3 computers connected to the same router
  • This router sometimes gets restarted so the IP adress for the machines might change
  • Every time this happens I edit /etc/hosts file updating IP address of machines named (master, slave1, slave2) and it tells that this machine will be added.

At first when I configured SSH generating the key and copying it to other machines it worked perfectly, I could use ssh slave1 from master and logging in with no password prompt:

  • I have edited sshd_config file and changed PubkeyAuthentication to no
  • Tried regenerating ssh key and used ssh-copy-id to copy it again to other computers (something like ssh-copy-id ~/.ssh/id_rsa.pub user@hostin all computers)

It's ok for me to change the IP adress manually because I had big trouble trying to make IP address static, but I need to use ssh host with no password prompt.

1
  • yeah i was confused, I should have set PasswordAuthentication to not and not PubkeyAuthentication Commented Aug 13, 2019 at 15:47

1 Answer 1

1

You need to set PubkeyAuthentication to yes in the sshd_config (on the server) to use the keys you've copied over.

(Once that is working you should also disable passwords with PasswordAuthentication no to prevent brute force guessing).

Instead of editing /etc/hosts (which requires root privileges) you can edit or create a user config ~/.ssh/config. (This only applies to ssh though). It would look something like:

Host slave1 Hostname 192.168.1.101 User bob IdentityFile ~/.ssh/id_rsa PubkeyAuthentication yes` Host slave2 Hostname 192.168.1.102 User bobby` Host master Hostname 192.168.1.100 User admin` 

Replace 192.x.x.x with your addresses and change it to your needs (man ssh_config is a great help here).

With this you will be able to type ssh slave1 and have all kinds of settings applied.

sshd_config configures the SSH server and ssh_config configures the SSH client (for all users) and per user in ~/.ssh/config.

The issue of changing IP addresses is best discussed in a separate question but I'd look into locking the DHCP leases (if you have access to the router), looking into putting inform 192.168.1.101 in /etc/dhcpcd.conf (if you use dhcpcd) or giving static IP addresses another go.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.