티스토리 뷰

OS/Linux

[Linux] SSH (/etc/ssh/sshd_config)

SweetDev 2022. 11. 3. 14:06

파일 위치:

/etc/ssh/sshd_config

 

 Port 22                            

 - ssh 사용할 기본 포트 지정        

 

Allowusers user1 root  

- 로그인 허락할 계정 기록한. 

- user1 root 두 계정에게만 로그인 허용

 

Protocol 2                         

- openssh 프로토콜 버전을 원하는 대로 선택할 수 있다. 

  protocol 2로 설정에는서버는 버전 2로만 작동하기 때문에 

  ssh1을 사용해 접속을 요청하는 클라이언트를 받아 들일 수 없다.

- protocol 1 설정해서 가동시킬 경우에는 버전 2를 사용하는 ssh2 사용자의 요청을 

 ​받아 들일 수 없다 보안상 protocol 1 은 사용하지 않는다.

 

 

ListenAddress 0.0.0.0        

- sshd 데몬이 통신가능한 주소이다. 0.0.0.0은 모든 네트워크

 

 

# HostKey for protocol version 1

# HostKey /etc/ssh/ssh_host_key        => protocol version 1 사용하지 않는다.

 - protocol 1.3 1.5에 의해 사용되어지는 private RSA 호스트 키 값이 

  저장되어 있는 파일이다 현재는 /etc/ssh/ssh_host_key 저장되어 있다. 

    pulick key(공개키) /etc/ssh/ssh_host_key.pub이다.

 

 

# KeyRegenerationInterval 3600                => protocol version 1 사용하지 않는다.

 - 서버의 키는 한번 접속이 이루어진 뒤에 자동적으로 다시 만들어진다. 

   다시 만드는 목적은 나중에 호스트의 세션에 있는 키를 캡처해서 

  암호를 해독하거나 훔친 키를 사용하지 못하도록 하기 위함 위함이다. 

   ​값이 0이면 키는 다시 만들어지지 않는다. 본값은 3600이다. 

  이값은 자동으로 키를 재생성하기 전까지 서버가 대기할 시간을 초단위로 정의한다.

 

 

# ServerKeyBits 1024                        => protocol version 1 사용하지 않는다. 

- 서버 키에서 어느정도의 비트수를 사용할지 정의한다. 

- ​최소값은 512이고 디폴트 값은 768이다. 

// 2048 권장

 

              

#Authentication:

LoginGraceTime 600

 유저의 로그인이 성공적으로 이루어지 않았을 때 이 시간 후에 서버가 

 ​ 연결을 끊는 시간이다. 

- 값이 0이면 제한    시간이 없다. 기본값은 600이다. 

 

 

PermitRootLogin no   ==> 보안상 no로 해준다. 

- root 로그인 허용여부를 결정하는 것이다. yes, no, without-password를 사용할 수 있다. 

현재 no로 되어 있기 때문에 직접 root로 접속이 불가능하다. 이옵션을 yes 로 하기보다는 

일반계정으로 로그인후 su 명령으로 root로 전환하는 것이 보안상 안전하다.        

  

 

PasswordAuthentication yes         

- 패스워드 인증을 허용한다. 이 옵션은 프로토콜 버전 1 2 모두 적용된다. 

인증할 때 암호기반 인증방법의 사용 여부를 결정한다. 

강력한 보안을 위해 이옵션은 항상 ‘no‘로 설정해야한다.

 

 

PermitEmptyPasswords no

- 패스워드 인증을 할 때 서버가 비어있는 패스워드를 인정하는 것이다. 

  ​기본 값 no이다.

 

출처: https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=jsky10503&logNo=220749042597 

내 서버 파일

더보기

# $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj 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 override the
# default value.

Include /etc/ssh/sshd_config.d/*.conf


Forwarding no 
Port 22
#Port 1125 
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

# override default of no subsystems
Subsystem sftp /usr/lib/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server

X11DisplayOffsetSpecifies the first display number available for sshd(8)'s X11 forwarding. This prevents sshd from interfering with real X11 servers. The default is 10.

 

X11ForwardingSpecifies whether X11 forwarding is permitted. The argument must be yes or no. The default is no.

When X11 forwarding is enabled, there may be additional exposure to the server and to client displays if the sshd(8) proxy display is configured to listen on the wildcard address (see X11UseLocalhost), though this is not the default. Additionally, the authentication spoofing and authentication data verification and substitution occur on the client side. The security risk of using X11 forwarding is that the client's X11 display server may be exposed to attack when the SSH client requests forwarding (see the warnings for ForwardX11 in ssh_config(5)). A system administrator may have a stance in which they want to protect clients that may expose themselves to attack by unwittingly requesting X11 forwarding, which can warrant a no setting.

Note that disabling X11 forwarding does not prevent users from forwarding X11 traffic, as users can always install their own forwarders.

X11UseLocalhostSpecifies whether sshd(8) should bind the X11 forwarding server to the loopback address or to the wildcard address. By default, sshd binds the forwarding server to the loopback address and sets the hostname part of the DISPLAY environment variable to localhost. This prevents remote hosts from connecting to the proxy display. However, some older X11 clients may not function with this configuration. X11UseLocalhost may be set to no to specify that the forwarding server should be bound to the wildcard address. The argument must be yes or no. The default is yes.

 

XAuthLocationSpecifies the full pathname of the xauth(1) program, or none to not use one. The default is /usr/X11R6/bin/xauth.

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함