기본 정보는 다음과 같습니다.
$ which ssh
/opt/local/bin/ssh
그 이유는 제가 MacPorts를 사용하고 있는데 실제로 MacPorts가 설치되어 있기 때문입니다. 내가 그랬어sudo port load openssh
grep은 netstat -an이 실행될 때 다시 시작을 수신합니다. 나는 이것을 가지고있다:
tcp4 0 0 *.2222 *.* LISTEN
tcp6 0 0 *.2222 *.* LISTEN
tcp46 0 0 *.5900 *.* LISTEN
tcp4 0 0 *.88 *.* LISTEN
tcp6 0 0 *.88 *.* LISTEN
tcp4 0 0 *.631 *.* LISTEN
tcp6 0 0 *.631 *.* LISTEN
tcp4 0 0 *.22 *.* LISTEN
tcp6 0 0 *.22 *.* LISTEN
tcp4 0 0 *.139 *.* LISTEN
tcp4 0 0 *.445 *.* LISTEN
tcp4 0 0 *.548 *.* LISTEN
tcp6 0 0 *.548 *.* LISTEN
tcp4 0 0 127.0.0.1.631 *.* LISTEN
tcp6 0 0 ::1.631 *.* LISTEN
그런 다음 nmap의 결과는 다음과 같습니다.
[email protected] ~ nmap -p 22 localhost 0 --15:23--
Starting Nmap 5.50 ( http://nmap.org ) at 2011-02-10 15:24 CET
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000083s latency).
PORT STATE SERVICE
22/tcp open ssh
Nmap done: 1 IP address (1 host up) scanned in 0.19 seconds
[email protected] ~ nmap -p 2222 localhost 0 --15:24--
Starting Nmap 5.50 ( http://nmap.org ) at 2011-02-10 15:25 CET
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000072s latency).
PORT STATE SERVICE
2222/tcp open EtherNet/IP-1
Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds
이제 localhost에서 ssh를 시도하면 어떻게 될까요?
[email protected] ~ ssh localhost 0 --15:30--
Connection closed by 127.0.0.1
포트 2222를 지정할 때.
[email protected] ~ ssh localhost -p 2222 255 --15:31--
Last login: Thu Feb 10 15:18:00 2011 from localhost
성공! 원인: /opt/local/etc/ 위치의 sshd_config 파일에서 찾았습니다. 포트 2222 파일은 여기에 있습니다:
[email protected] ~ cat /opt/local/etc/ssh/sshd_config | less 0 --15:29--
# $OpenBSD: sshd_config,v 1.81 2009/10/08 14:03:41 markus Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
Port 2222
그래서 해당 파일의 포트를 22로 변경하기로 결정했습니다.
다음과 같이 언로드/로드하여 서비스를 다시 시작합니다.
[email protected] /opt/local/etc/ssh ssh localhost -p 2222 0 --15:35--
Last login: Thu Feb 10 15:32:15 2011 from localhost
[email protected] ~ sudo port unload openssh 0 --15:35--
[email protected] ~ sudo port load openssh 0 --15:36--
[email protected] ~ ssh localhost -p 2222 0 --15:36--
ssh: connect to host localhost port 2222: Connection refused
글쎄요, 운이 좋다고 생각합니다. SSH localhost를 사용해 봅니다.
[email protected] ~ ssh localhost 255 --15:36--
Connection closed by 127.0.0.1
아무래도 행운은 없는 것 같아요. 이것은 -vv 명령입니다:
[email protected] ~ ssh -vv localhost 255 --15:37--
OpenSSH_5.6p1, OpenSSL 1.0.0c 2 Dec 2010
debug1: Reading configuration data /opt/local/etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type '-----END'
debug1: identity file /Users/pierre/.ssh/id_rsa type 1
debug1: identity file /Users/pierre/.ssh/id_rsa-cert type -1
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type '-----END'
debug1: identity file /Users/pierre/.ssh/id_dsa type 2
debug1: identity file /Users/pierre/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_5.2
debug1: match: OpenSSH_5.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 127/256
debug2: bits set: 520/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /Users/pierre/.ssh/known_hosts:1
debug2: bits set: 534/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /Users/pierre/.ssh/id_rsa (0x10030e540)
debug2: key: /Users/pierre/.ssh/id_dsa (0x10031dcf0)
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/pierre/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
Connection closed by 127.0.0.1
어떻게 생각하나요?
답변1
OS X에는 sshd
이미 이 기능이 포함되어 있습니다. 시스템 환경설정의 공유에서 원격 로그인을 활성화하면 작동합니다.
기본이 아닌 포트에서 수신 대기하려는 경우 요령은 다음과 같습니다.
/System/Library/LaunchDaemons/ssh.plist
즐겨 사용하는 텍스트 편집기에서 엽니다.SockServiceName
문제의 핵심을 찾아보세요 .문자열 값을 비슷한 값으로 변경
ssh-alt
하고 plist 파일을 저장합니다.ssh-alt
파일에 항목을 추가합니다/etc/services
.공유 환경 설정 창으로 이동하여 원격 로그인 확인란을 껐다가 켜십시오. 이제 컴퓨터가
sshd
다른 포트에서 수신 대기하고 있음을 알 수 있습니다.
이 모든 것을 피하기 위해 편집할 수 있다고 생각할 수도 있지만 /etc/sshd_config
, 이는 틀렸습니다. 기본적으로 sshd
plist 파일에만 중점을 둡니다.