Versions Compared

Key

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

...

Configuring /etc/rc.local for loading on different nodes with different IP addresses.

Note this will be automated in a future release.

The script /etc/rc.local is used to determine the correct IP addresses and update sshd_config and external_sshd_config files.

...

Code Block
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.ORIG
perl -pi -e 's/^X11Forwarding .*$/X11Forwarding yes/' /etc/ssh/sshd_config
perl -pi -e 's/^KeyRegenerationInterval .*$/KeyRegenerationInterval 0/' /etc/ssh/sshd_config
perl -pi -e 's/(.*MaxStartups.*)/#\1/' /etc/ssh/sshd_config
	
cp /etc/ssh/sshd_config /etc/ssh/external_sshd_config
perl -pi -e 's/.*PidFile .*$/PidFile \/var\/run\/ext_sshd.pid/' /etc/ssh/external_sshd_config

IP0=\$(ifconfig eth0 | grep 'inet addr' | awk '{print \$2}' | awk -F: '{print \$2}')
IP1=\$(ifconfig eth1 | grep 'inet addr' | awk '{print \$2}' | awk -F: '{print \$2}')
perl -pi -e 's/^AllowUsers .*\n//' /etc/ssh/sshd_config
perl -pi -e 's/^AllowUsers .*\n//' /etc/ssh/external_sshd_config
perl -pi -e 's/^ListenAddress .*\n//' /etc/ssh/sshd_config
perl -pi -e 's/^ListenAddress .*\n//' /etc/ssh/external_sshd_config
echo \"AllowUsers root\" >> /etc/ssh/sshd_config
echo \"ListenAddress \$IP0\" >> /etc/ssh/sshd_config
echo \"ListenAddress \$IP1\" >> /etc/ssh/external_sshd_config
/etc/rc.d/init.d/sshd stop
sleep 2
/etc/rc.d/init.d/sshd start

  • Note: If adapters are reserved i.e, private network is on eth1 and public is eth0. Change the above IP0 and IP1 lines.
    Code Block
    
    IP1=\$(ifconfig eth0 | grep 'inet addr' | awk '{print \$2}' | awk -F: '{print \$2}')
    IP0=\$(ifconfig eth1 | grep 'inet addr' | awk '{print \$2}' | awk -F: '{print \$2}')
    

Create the startup script ext_sshd

Note this will be automated in a future release.

  • copy /etc/init.d/sshd /etc/init.d/ext_sshd
    Code Block
    
    cp /etc/init.d/sshd /etc/init.d/ext_sshd
    
  • Edit /etc/init.d/ext_sshd with your favorite editor
    Set or change the following variables OPTIONS PID_FILE
    Code Block
    
    OPTIONS='-f /etc/ssh/external_sshd_config'
    PID_FILE=/var/run/ext_sshd.pid