summaryrefslogtreecommitdiff
path: root/contrib/cygwin
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-03-07 21:38:19 +1100
committerDamien Miller <djm@mindrot.org>2001-03-07 21:38:19 +1100
commit8ac0a7ec448764036e1a1657013a9fd9179be860 (patch)
tree4db958c3fa4b9982b37a362d9e65b5dd94ed5b5b /contrib/cygwin
parentb29e34d1e491ac07ed294c51462e3611951a8379 (diff)
- Cygwin contrib improvements from Corinna Vinschen <vinschen@redhat.com>
Diffstat (limited to 'contrib/cygwin')
-rw-r--r--contrib/cygwin/README9
-rw-r--r--contrib/cygwin/ssh-host-config89
2 files changed, 80 insertions, 18 deletions
diff --git a/contrib/cygwin/README b/contrib/cygwin/README
index ac0955836..dd237f2ca 100644
--- a/contrib/cygwin/README
+++ b/contrib/cygwin/README
@@ -15,12 +15,8 @@ filesystem (which is recommended) due to the lack of any basic security
15features of the FAT/FAT32 filesystems. 15features of the FAT/FAT32 filesystems.
16=========================================================================== 16===========================================================================
17 17
18Since this package is part of the base distribution now, the location 18If you are installing OpenSSH the first time, you can generate global config
19of the files has changed from /usr/local to /usr. The global configuration 19files and server keys by running
20files are in /etc now.
21
22If you are installing OpenSSH the first time, you can generate
23global config files and server keys by running
24 20
25 /usr/bin/ssh-host-config 21 /usr/bin/ssh-host-config
26 22
@@ -39,6 +35,7 @@ Options:
39 --debug -d Enable shell's debug output. 35 --debug -d Enable shell's debug output.
40 --yes -y Answer all questions with "yes" automatically. 36 --yes -y Answer all questions with "yes" automatically.
41 --no -n Answer all questions with "no" automatically. 37 --no -n Answer all questions with "no" automatically.
38 --port -p <n> sshd listens on port n.
42 39
43You can create the private and public keys for a user now by running 40You can create the private and public keys for a user now by running
44 41
diff --git a/contrib/cygwin/ssh-host-config b/contrib/cygwin/ssh-host-config
index 6fe2c7795..70bbafdb7 100644
--- a/contrib/cygwin/ssh-host-config
+++ b/contrib/cygwin/ssh-host-config
@@ -16,6 +16,7 @@ OLDSYSCONFDIR=${OLDPREFIX}/etc
16 16
17progname=$0 17progname=$0
18auto_answer="" 18auto_answer=""
19port_number=22
19 20
20request() 21request()
21{ 22{
@@ -67,6 +68,11 @@ do
67 auto_answer=no 68 auto_answer=no
68 ;; 69 ;;
69 70
71 -p | --port )
72 port_number=$1
73 shift
74 ;;
75
70 *) 76 *)
71 echo "usage: ${progname} [OPTION]..." 77 echo "usage: ${progname} [OPTION]..."
72 echo 78 echo
@@ -76,6 +82,7 @@ do
76 echo " --debug -d Enable shell's debug output." 82 echo " --debug -d Enable shell's debug output."
77 echo " --yes -y Answer all questions with \"yes\" automatically." 83 echo " --yes -y Answer all questions with \"yes\" automatically."
78 echo " --no -n Answer all questions with \"no\" automatically." 84 echo " --no -n Answer all questions with \"no\" automatically."
85 echo " --port -p <n> sshd listens on port n."
79 echo 86 echo
80 exit 1 87 exit 1
81 ;; 88 ;;
@@ -254,6 +261,11 @@ Host *
254 IdentityFile ~/.ssh/id_rsa 261 IdentityFile ~/.ssh/id_rsa
255 IdentityFile ~/.ssh/id_dsa 262 IdentityFile ~/.ssh/id_dsa
256EOF 263EOF
264 if [ "$port_number" != "22" ]
265 then
266 echo "Host localhost" >> ${SYSCONFDIR}/ssh_config
267 echo " Port $port_number" >> ${SYSCONFDIR}/ssh_config
268 fi
257fi 269fi
258 270
259# Check if sshd_config exists. If yes, ask for overwriting 271# Check if sshd_config exists. If yes, ask for overwriting
@@ -278,7 +290,7 @@ then
278 cat > ${SYSCONFDIR}/sshd_config << EOF 290 cat > ${SYSCONFDIR}/sshd_config << EOF
279# This is ssh server systemwide configuration file. 291# This is ssh server systemwide configuration file.
280 292
281Port 22 293Port $port_number
282# 294#
283Protocol 2,1 295Protocol 2,1
284ListenAddress 0.0.0.0 296ListenAddress 0.0.0.0
@@ -330,7 +342,7 @@ UseLogin no
330EOF 342EOF
331fi 343fi
332 344
333# Add port 22/tcp to services 345# Care for services file
334_sys="`uname -a`" 346_sys="`uname -a`"
335_nt=`expr "$_sys" : "CYGWIN_NT"` 347_nt=`expr "$_sys" : "CYGWIN_NT"`
336if [ $_nt -gt 0 ] 348if [ $_nt -gt 0 ]
@@ -344,33 +356,86 @@ fi
344_services=`cygpath -u "${_wservices}"` 356_services=`cygpath -u "${_wservices}"`
345_serv_tmp=`cygpath -u "${_wserv_tmp}"` 357_serv_tmp=`cygpath -u "${_wserv_tmp}"`
346 358
347mount -b -f "${_wservices}" "${_services}" 359mount -t -f "${_wservices}" "${_services}"
348mount -b -f "${_wserv_tmp}" "${_serv_tmp}" 360mount -t -f "${_wserv_tmp}" "${_serv_tmp}"
361
362# Remove sshd 22/port from services
363if [ `grep -q 'sshd[ \t][ \t]*22' "${_services}"; echo $?` -eq 0 ]
364then
365 grep -v 'sshd[ \t][ \t]*22' "${_services}" > "${_serv_tmp}"
366 if [ -f "${_serv_tmp}" ]
367 then
368 if mv "${_serv_tmp}" "${_services}"
369 then
370 echo "Removing sshd from ${_services}"
371 else
372 echo "Removing sshd from ${_services} failed\!"
373 fi
374 rm -f "${_serv_tmp}"
375 else
376 echo "Removing sshd from ${_services} failed\!"
377 fi
378fi
349 379
350if [ `grep -q 'sshd[ \t][ \t]*22' "${_services}"; echo $?` -ne 0 ] 380# Add ssh 22/tcp and ssh 22/udp to services
381if [ `grep -q 'ssh[ \t][ \t]*22' "${_services}"; echo $?` -ne 0 ]
351then 382then
352 awk '{ if ( $2 ~ /^23\/tcp/ ) print "sshd 22/tcp #SSH daemon\r"; print $0; }' < "${_services}" > "${_serv_tmp}" 383 awk '{ if ( $2 ~ /^23\/tcp/ ) print "ssh 22/tcp #SSH Remote Login Protocol\nssh 22/udp #SSH Remote Login Protocol"; print $0; }' < "${_services}" > "${_serv_tmp}"
353 if [ -f "${_serv_tmp}" ] 384 if [ -f "${_serv_tmp}" ]
354 then 385 then
355 if mv "${_serv_tmp}" "${_services}" 386 if mv "${_serv_tmp}" "${_services}"
356 then 387 then
357 echo "Added sshd to ${_services}" 388 echo "Added ssh to ${_services}"
358 else 389 else
359 echo "Adding sshd to ${_services} failed\!" 390 echo "Adding ssh to ${_services} failed\!"
360 fi 391 fi
361 rm -f "${_serv_tmp}" 392 rm -f "${_serv_tmp}"
362 else 393 else
363 echo "Adding sshd to ${_services} failed\!" 394 echo "Adding ssh to ${_services} failed\!"
364 fi 395 fi
365fi 396fi
366 397
367umount "${_services}" 398umount "${_services}"
368umount "${_serv_tmp}" 399umount "${_serv_tmp}"
369 400
370# Add sshd line to inetd.conf 401# Care for inetd.conf file
371if [ -f /etc/inetd.conf ] 402_inetcnf="/etc/inetd.conf"
403_inetcnf_tmp="/etc/inetd.conf.$$"
404
405if [ -f "${_inetcnf}" ]
372then 406then
373 grep -q "^[# \t]*sshd" /etc/inetd.conf || echo "# sshd stream tcp nowait root /usr/sbin/sshd -i" >> /etc/inetd.conf 407 # Check if ssh service is already in use as sshd
408 with_comment=1
409 grep -q '^[ \t]*sshd' "${_inetcnf}" && with_comment=0
410 # Remove sshd line from inetd.conf
411 if [ `grep -q '^[# \t]*sshd' "${_inetcnf}"; echo $?` -eq 0 ]
412 then
413 grep -v '^[# \t]*sshd' "${_inetcnf}" >> "${_inetcnf_tmp}"
414 if [ -f "${_inetcnf_tmp}" ]
415 then
416 if mv "${_inetcnf_tmp}" "${_inetcnf}"
417 then
418 echo "Removed sshd from ${_inetcnf}"
419 else
420 echo "Removing sshd from ${_inetcnf} failed\!"
421 fi
422 rm -f "${_inetcnf_tmp}"
423 else
424 echo "Removing sshd from ${_inetcnf} failed\!"
425 fi
426 fi
427
428 # Add ssh line to inetd.conf
429 if [ `grep -q '^[# \t]*ssh' "${_inetcnf}"; echo $?` -ne 0 ]
430 then
431 if [ "${with_comment}" -eq 0 ]
432 then
433 echo 'ssh stream tcp nowait root /usr/sbin/sshd -i' >> "${_inetcnf}"
434 else
435 echo '# ssh stream tcp nowait root /usr/sbin/sshd -i' >> "${_inetcnf}"
436 fi
437 echo "Added ssh to ${_inetcnf}"
438 fi
374fi 439fi
375 440
376if [ "${old_install}" = "1" ] 441if [ "${old_install}" = "1" ]