Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <000c01c0a531$5f64dc80$0164a8c0@mn.mediaone.net> From: "CyberZombie" To: "Corinna Vinschen" References: <010601c0a37f$e2f7d240$1d1587a8 AT deluxe DOT com> <20010304230213 DOT B1398 AT cygbert DOT vinschen DOT de> Subject: Re: ssh-host-config change request Date: Sun, 4 Mar 2001 23:01:43 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 > Looks nice. Could you please send me a diff -up? It's way easier > to read and apply. I made one more update to also put the requested port into ssh_config. One thing -- should the generation of ssh_config be part of ssh-user-config rather than ssh-host-config? --- /bin/ssh-host-config Thu Mar 1 02:28:30 2001 +++ /home/root/ssh-newhost-config Sun Mar 4 22:53:30 2001 @@ -16,6 +16,7 @@ OLDSYSCONFDIR=${OLDPREFIX}/etc progname=$0 auto_answer="" +port_number=22 request() { @@ -67,6 +68,11 @@ do auto_answer=no ;; + -p | --port ) + port_number=$1 + shift + ;; + *) echo "usage: ${progname} [OPTION]..." echo @@ -76,6 +82,7 @@ do echo " --debug -d Enable shell's debug output." echo " --yes -y Answer all questions with \"yes\" automatically." echo " --no -n Answer all questions with \"no\" automatically." + echo " --port -p sshd listens on port n." echo exit 1 ;; @@ -247,6 +254,10 @@ then IdentityFile ~/.ssh/id_rsa IdentityFile ~/.ssh/id_dsa EOF + if [ "$port_number" != "22" ] + then + echo " Port $port_number" >> ${SYSCONFDIR}/ssh_config + fi fi # Check if sshd_config exists. If yes, ask for overwriting @@ -272,7 +283,7 @@ then # This is the sshd server system-wide configuration file. See sshd(8) # for more information. -Port 22 +Port $port_number #Protocol 2,1 #ListenAddress 0.0.0.0 #ListenAddress :: @@ -325,7 +336,7 @@ Subsystem sftp /usr/sbin/sftp-se EOF fi -# Add port 22/tcp to services +# Add port $port_number/tcp to services _sys="`uname -a`" _nt=`expr "$_sys" : "CYGWIN_NT"` if [ $_nt -gt 0 ] @@ -342,11 +353,28 @@ _serv_tmp=`cygpath -u "${_wserv_tmp}"` mount -b -f "${_wservices}" "${_services}" mount -b -f "${_wserv_tmp}" "${_serv_tmp}" -if [ `grep -q 'sshd[ \t][ \t]*22' "${_services}"; echo $?` -ne 0 ] +cat > /tmp/sshd_awk.$$ << EOF +\$1 == "sshd" { next } +! finished && \$2 + 0 >= $port_number { + finished = 1 + if ( \$2 + 0 == $port_number ) { + # Problem -- non-sshd port assignment already exists. + } else { + print "sshd $port_number/tcp #SSH daemon\r" + } +} +{ print \$0 } +EOF + +awk -f /tmp/sshd_awk.$$ < "${_services}" > "${_serv_tmp}" +rm -f /tmp/sshd_awk.$$ + +if [ -f "${_serv_tmp}" ] then - awk '{ if ( $2 ~ /^23\/tcp/ ) print "sshd 22/tcp #SSH daemon\r"; print $0; }' < "${_services}" > "${_serv_tmp}" - if [ -f "${_serv_tmp}" ] + if [ `egrep -q '^sshd[ \t]' "${_serv_tmp}"; echo $?` -ne 0 ] then + echo "Unable to add sshd to ${_services} as port $port_number already in use" + else if mv "${_serv_tmp}" "${_services}" then echo "Added sshd to ${_services}" @@ -354,9 +382,9 @@ then echo "Adding sshd to ${_services} failed\!" fi rm -f "${_serv_tmp}" - else - echo "Adding sshd to ${_services} failed\!" fi +else + echo "Adding sshd to ${_services} failed\!" fi umount "${_services}" -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple