# 1.1. configure sshd sudo cp $SSHD_FILE${SSHD_FILE}.`date '+%Y-%m-%d_%H-%M-%S'`.back sudo sed -i '/^Port/ d'$SSHD_FILE sudo sed -i '/^ListenAddress/ d'$SSHD_FILE sudo sed -i '/^UsePrivilegeSeparation/ d'$SSHD_FILE sudo sed -i '/^PasswordAuthentication/ d'$SSHD_FILE echo"# configured by CLion" | sudo tee -a $SSHD_FILE echo"ListenAddress ${SSHD_LISTEN_ADDRESS}" | sudo tee -a $SSHD_FILE echo"Port ${SSHD_PORT}" | sudo tee -a $SSHD_FILE echo"UsePrivilegeSeparation no" | sudo tee -a $SSHD_FILE echo"PasswordAuthentication yes" | sudo tee -a $SSHD_FILE # 1.2. apply new settings sudo service ssh --full-restart # 2. autostart: run sshd sed -i '/^sudo service ssh --full-restart/ d' ~/.bashrc echo"%sudo ALL=(ALL) NOPASSWD: /usr/sbin/service ssh --full-restart" | sudo tee -a $SUDOERS_FILE cat << 'EOF' >> ~/.bashrc sshd_status=$(service ssh status) if [[ $sshd_status = *"is not running"* ]]; then sudo service ssh --full-restart fi EOF
# summary: SSHD config info echo echo"SSH server parameters ($SSHD_FILE):" echo"ListenAddress ${SSHD_LISTEN_ADDRESS}" echo"Port ${SSHD_PORT}" echo"UsePrivilegeSeparation no" echo"PasswordAuthentication yes"