Cambiar puerto por defecto ssh Mac OS X

cerros

Nuev@ Applesan@
El Leopard asigna el puerto 22 al ssh ¿hay manera de cambiarlo? no encuentro el fichero de configuración.

Gracias.
 

juker12

Nuev@ Applesan@
cerros no solo lo puedes cambiar si no crear tantos servicios como tu quieras, esto puede ser muy util en grandes organizaciones con varios admin

Edita con sudo desde terminal
sudo nano /etc/sshd_config

añade un nuevo puerto, (en negrita mi ejemplo)
Código:
  GNU nano 2.0.1                  File: /etc/sshd_config                                           

#       $OpenBSD: sshd_config,v 1.74 2006/07/19 13:07:10 dtucker Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

Port 22
[B]Port 2880[/B]
Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh_host_rsa_key
#HostKey /etc/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key

^G Get Help     ^O WriteOut     ^R Read File    ^Y Prev Page    ^K Cut Text     ^C Cur Pos
^X Exit         ^J Justify      ^W Where Is     ^V Next Page    ^U UnCut Text   ^T To Spell

Y guarda cambios

Ahora create un servicio
cd /System/Library/LaunchDaemons

y haces una copia de seguridad de ssh.plist, en terminal
sudo cp ssh.plist ssh2.plist

Vas a crear un duplicado, fijate en la negrita

Código:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Disabled</key>
	<true/>
	<key>Label</key>
	<string>com.openssh.sshd</string>
        [B]<string>com.openssh2.sshd</string>[/B]
	<key>Program</key>
	<string>/usr/libexec/sshd-keygen-wrapper</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/sbin/sshd</string>
		<string>-i</string>
	</array>
	<key>Sockets</key>
	<dict>
		<key>Listeners</key>
		<dict>
			<key>SockServiceName</key>
			<string>ssh</string>
                        [B]<string>ssh2</string>[/B]
			<key>Bonjour</key>
			<array>
				<string>ssh</string>
				<string>sftp-ssh</string>
			</array>
		</dict>
	</dict>
	<key>inetdCompatibility</key>
	<dict>
		<key>Wait</key>
		<false/>
	</dict>
	<key>SessionCreate</key>
	<true/>
	<key>StandardErrorPath</key>
	<string>/dev/null</string>
        <key>SHAuthorizationRight</key>
        <string>system.preferences</string>
</dict>
</plist>


Por ultimo, en /etc/services añade el nuevo puerto y servicio

Código:
#
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
#
# The latest IANA port assignments can be gotten from
#
#	http://www.iana.org/assignments/port-numbers
#
# The Well Known Ports are those from 0 through 1023.
# The Registered Ports are those from 1024 through 49151
# The Dynamic and/or Private Ports are those from 49152 through 65535
#
# $FreeBSD: src/etc/services,v 1.89 2002/12/17 23:59:10 eric Exp $
#	From: (#)services	5.8 (Berkeley) 5/9/91
#
# WELL KNOWN PORT NUMBERS
#
rtmp              1/ddp    #Routing Table Maintenance Protocol
tcpmux            1/udp     # TCP Port Service Multiplexer
tcpmux            1/tcp     # TCP Port Service Multiplexer
#                          Mark Lottor <MKLnisc.sri.com>

[B]sigue abajo buscando  hasta aqui........[/B]
#                          Jon Postel <postelisi.edu>
ssh              22/udp     # SSH Remote Login Protocol
ssh              22/tcp     # SSH Remote Login Protocol

[B]añade[/B]

ssh2           2880/udp     # SSH Remote Login Protocol añadido
ssh2           2880/tcp     # SSH Remote Login Protocol añadido



En mi ejemplo el puerto deseado fue 2880

Para conectar en terminal
ssh jukerapplesana.com -p 2880
 
Arriba