In order to lock down the servers like I prefer to, yet still allow FreeNX/NX to work, I have to setup a second copy of the sshd daemon. The FreeNX/NX client requires that you have sshd running with password access (not just public key), but we prefer to only allow public-key access to our servers.
I did the following on CentOS 5, it should also work for Fedora or Red Hat Enterprise Linux (RHEL). But proceed at your own risk.
1) Create a hard link to the sshd program. This allows us to distinguish it in the process list. It also makes sure that our cloned copy stays up to date as the sshd program is patched.
# ln /usr/sbin/sshd /usr/sbin/sshd_nx
2) Copy /etc/init.d/sshd to a new name
This is the startup / shutdown script for the base sshd daemon. Make a copy of this script:
# cp -p /etc/init.d/sshd /etc/init.d/sshd
_nx# vi /etc/init.d/sshd_nx
Change the following lines:
# processname: sshd
_nx# config: /etc/ssh/sshd
_nx_config
# pidfile: /var/run/sshd
_nx.pid
prog="sshd
_nx"
SSHD=/usr/sbin/sshd
_nxPID_FILE=/var/run/sshd
_nx.pid
OPTIONS="-f /etc/ssh/sshd_nx_config -o PidFile=${PID_FILE} ${OPTIONS}"
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/sshd
_nx[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/sshd
_nxif [ -f /var/lock/subsys/sshd
_nx ] ; then
Note: The OPTIONS= line is probably new and will have to be added right after the PID_FILE= line in the file. There are also multiple lines that reference /var/lock/subsys/sshd, you will need to change all of them.
3) Copy the old sshd configuration file.
# cp -p /etc/ssh/sshd_config /etc/ssh/sshd
_nx_config
4) Edit the new sshd configuration file and make sure that it uses a different port number.
Port 28822
5) Clone the PAM configuration file.
# cp -p /etc/pam.d/sshd /etc/pam.d/sshd
_nx6) Set the new service to startup automatically.
# chkconfig --add sshd
_nx...
Test it out
# service sshd_nx start
# ssh -p 28222 username@localhost
Check for errors in the log file:
# tail -n 25 /var/log/secure
...
At this point, I would go back and change the secondary configuration to only listen on the localhost ports:
ListenAddress 127.0.0.1
ListenAddress ::1
...
References:
How to Add a New "sshd_adm" Service on Red Hat Advanced Server 2.1How to install NX server and client under Ubuntu/Kubuntu Linux (revised)Labels: 2009, FreeNX, NX, SSH
posted by Thomas at
09:57