diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/cygwin/README | 9 | ||||
-rw-r--r-- | contrib/cygwin/ssh-host-config | 89 |
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 | |||
15 | features of the FAT/FAT32 filesystems. | 15 | features of the FAT/FAT32 filesystems. |
16 | =========================================================================== | 16 | =========================================================================== |
17 | 17 | ||
18 | Since this package is part of the base distribution now, the location | 18 | If you are installing OpenSSH the first time, you can generate global config |
19 | of the files has changed from /usr/local to /usr. The global configuration | 19 | files and server keys by running |
20 | files are in /etc now. | ||
21 | |||
22 | If you are installing OpenSSH the first time, you can generate | ||
23 | global 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 | ||
43 | You can create the private and public keys for a user now by running | 40 | You 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 | ||
17 | progname=$0 | 17 | progname=$0 |
18 | auto_answer="" | 18 | auto_answer="" |
19 | port_number=22 | ||
19 | 20 | ||
20 | request() | 21 | request() |
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 |
256 | EOF | 263 | EOF |
264 | if [ "$port_number" != "22" ] | ||
265 | then | ||
266 | echo "Host localhost" >> ${SYSCONFDIR}/ssh_config | ||
267 | echo " Port $port_number" >> ${SYSCONFDIR}/ssh_config | ||
268 | fi | ||
257 | fi | 269 | fi |
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 | ||
281 | Port 22 | 293 | Port $port_number |
282 | # | 294 | # |
283 | Protocol 2,1 | 295 | Protocol 2,1 |
284 | ListenAddress 0.0.0.0 | 296 | ListenAddress 0.0.0.0 |
@@ -330,7 +342,7 @@ UseLogin no | |||
330 | EOF | 342 | EOF |
331 | fi | 343 | fi |
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"` |
336 | if [ $_nt -gt 0 ] | 348 | if [ $_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 | ||
347 | mount -b -f "${_wservices}" "${_services}" | 359 | mount -t -f "${_wservices}" "${_services}" |
348 | mount -b -f "${_wserv_tmp}" "${_serv_tmp}" | 360 | mount -t -f "${_wserv_tmp}" "${_serv_tmp}" |
361 | |||
362 | # Remove sshd 22/port from services | ||
363 | if [ `grep -q 'sshd[ \t][ \t]*22' "${_services}"; echo $?` -eq 0 ] | ||
364 | then | ||
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 | ||
378 | fi | ||
349 | 379 | ||
350 | if [ `grep -q 'sshd[ \t][ \t]*22' "${_services}"; echo $?` -ne 0 ] | 380 | # Add ssh 22/tcp and ssh 22/udp to services |
381 | if [ `grep -q 'ssh[ \t][ \t]*22' "${_services}"; echo $?` -ne 0 ] | ||
351 | then | 382 | then |
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 |
365 | fi | 396 | fi |
366 | 397 | ||
367 | umount "${_services}" | 398 | umount "${_services}" |
368 | umount "${_serv_tmp}" | 399 | umount "${_serv_tmp}" |
369 | 400 | ||
370 | # Add sshd line to inetd.conf | 401 | # Care for inetd.conf file |
371 | if [ -f /etc/inetd.conf ] | 402 | _inetcnf="/etc/inetd.conf" |
403 | _inetcnf_tmp="/etc/inetd.conf.$$" | ||
404 | |||
405 | if [ -f "${_inetcnf}" ] | ||
372 | then | 406 | then |
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 | ||
374 | fi | 439 | fi |
375 | 440 | ||
376 | if [ "${old_install}" = "1" ] | 441 | if [ "${old_install}" = "1" ] |