Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

where PWUSER is a user account and NEWPASSWORD is a new password.

Changing password of ubuntu account and preparing key-based ssh login environment in multiple VM nodes

Ubuntu account is available as a default account in addition to root account. You may want to use the ubuntu account as your main account to use the created cluster. The following script (https://github.com/astromsshin/cloud_ex/blob/main/tool_change_password_for_ubuntu_all_nodes_and_setup_sshkey.sh) helps you setup the environment with the ubuntu account by changing a password for the ubuntu account and adding a generated ssh key file to the right directory.

Code Block
languagebash
#!/bin/bash

# this script should be executed by root in the master node.

CLUSTERNAME="mycluster"
MINIONLASTIND="4"
PWUSER="ubuntu"
NEWPASSWORD="xxxxxxxxxx"

NFSDIR="/mnt/mpi"

# changing password of ubuntu account.

echo "... changing ${CLUSTERNAME}-master : ${PWUSER}"
echo -e "${NEWPASSWORD}\n${NEWPASSWORD}" | passwd ${PWUSER}

for ind in $(seq 0 ${MINIONLASTIND})
do
  echo "... changing ${CLUSTERNAME}-minion-${ind} : ${PWUSER}"
  ssh ${CLUSTERNAME}-minion-${ind} "echo -e \"${NEWPASSWORD}\n${NEWPASSWORD}\" | passwd ${PWUSER}"
done

# generate ssh-key
rm -f ${NFSDIR}/id_ed25519 ${NFSDIR}/id_ed25519.pub
### you should type empty passwords by entering twice.
ssh-keygen -t ed25519 << endskey
${NFSDIR}/id_ed25519
endskey

# setup the environemnt for ssh access without password among the cluster nodes
# for ubuntu account
### master
echo "setup the master: ${CLUSTERNAME}-master"
cp -f ${NFSDIR}/id_ed25519 /home/ubuntu/.ssh/
cp -f ${NFSDIR}/id_ed25519.pub /home/ubuntu/.ssh/
chown ubuntu:ubuntu /home/ubuntu/.ssh/id_ed25519*
chmod 600 /home/ubuntu/.ssh/id_ed25519
chmod 644 /home/ubuntu/.ssh/id_ed25519.pub
cat /home/ubuntu/.ssh/id_ed25519.pub >> /home/ubuntu/.ssh/authorized_keys
### slaves
for ind in $(seq 0 ${MINIONLASTIND})
do
  echo "setup the slave: ${CLUSTERNAME}-minion-${ind}"
  ssh ${CLUSTERNAME}-minion-${ind} "cp -f ${NFSDIR}/id_ed25519 /home/ubuntu/.ssh/; cp -f ${NFSDIR}/id_ed25519.pub /home/ubuntu/.ssh/; chown ubuntu:ubuntu /home/ubuntu/.ssh/id_ed25519*; chmod 600 /home/ubuntu/.ssh/id_ed25519; chmod 644 /home/ubuntu/.ssh/id_ed25519.pub; cat /home/ubuntu/.ssh/id_ed25519.pub >> /home/ubuntu/.ssh/authorized_keys"
done

The above script should be executed by root account. If you like to use a different type in stead of ed25519, you should modify the script.

Install Intel oneAPI and use its MPI

...