나는 배너/motd 표시 측면에서 일부 일관되지 않은 동작을 보이는 Solaris 10 서버 팜에서 작업합니다.
이번에는 한 서버에서 다른 서버로 scp를 수행하려고 합니다. 일부 서버에서는 배너가 표시되지 않고 일부 서버에서는 표시됩니다.
나는 이미 시도했습니다:
- .hushlogin 파일 생성
- scp -q
- scp -o LogLevel=오류
- /etc/ssh/sshd_config의 PrintMotd 번호
- /etc/ssh/ssh_config의 LogLevel QUIET
SSH를 사용할 때 이미 배너가 표시되지 않는데 scp가 포함된 배너가 일부 서버에 계속 남아 있어서 이를 끄는 방법을 찾고 싶습니다.
관리자 권한은 없지만 특정 구성에 대한 변경을 요청할 수 있습니다.
scp 세션 샘플:
usera@server20$ scp a.sh server43:/tmp
###################################################################
# This system is for the use of authorized users only. #
# Individuals using this computer system without authority, or in #
# excess of their authority, are subject to having all of their #
# activities on this system monitored and recorded by system #
# personnel. #
# #
# Anyone using this system expressly consents to such monitoring #
# and is advised that if such monitoring reveals possible #
# evidence of criminal activity, system personnel may provide the #
# evidence of such monitoring to law enforcement officials. #
###################################################################
WARNING: Access to this computer system is limited to authorised users only.
Unauthorised users may be subject to prosecution under the Crimes
Act or State legislation.
a.sh 100% |***********************************************************************************************************| 602 00:00
usera@server20$
팜에 있는 서버의 SSH 세션 샘플:
usera@server20$ ssh server43
LI002: usera is allowed 2 concurrent logins
Last login: Tue Jun 16 2015 17:30:05 from pts/2
server43:usera>
팜 외부의 SSH 세션 샘플:
login as: usera
###################################################################
# This system is for the use of authorized users only. #
# Individuals using this computer system without authority, or in #
# excess of their authority, are subject to having all of their #
# activities on this system monitored and recorded by system #
# personnel. #
# #
# Anyone using this system expressly consents to such monitoring #
# and is advised that if such monitoring reveals possible #
# evidence of criminal activity, system personnel may provide the #
# evidence of such monitoring to law enforcement officials. #
###################################################################
WARNING: Access to this computer system is limited to authorised users only.
Unauthorised users may be subject to prosecution under the Crimes
Act or State legislation.
Using keyboard-interactive authentication.
Password:
LI002: usera is allowed 2 concurrent logins
Last login: Tue Jun 16 2015 18:40:41 from pts/1
server43:usera>
답변1
이 SSH 서버가 원하는 접근 방식뿐만 아니라 일반 SSH 셸 세션도 수행하고 있음을 표시했습니다 sftp
. 또한 다음 답변은 가능한 가장 오래된 OpenSSH 버전에 적용됩니다. v4.0.0p1
(달리 명시된 경우 제외) 이 답변은 OpenSSH v6.6p1,REV=2014.03.20을 사용하는 최신 Solaris 10 및 11에 적용됩니다.
내 솔루션은 일반 SSH와 scp
/를 모두 제공합니다 sftp
.
설정
비결은 Match User sftp
SSH 서버 구성에서 몇 가지 설정을 사용하는 것입니다.
Banner
PrintMotd
Banner
Banner
설정은 인증이 허용되기 전에 지정된 파일의 내용이 원격 사용자에게 전송되는 파일 이름입니다. 인수가 이면 none
배너가 표시되지 않습니다. 기본적으로 배너는 표시되지 않습니다.
OP에 따르면 Banner yes
파일 어딘가에 있을 수 있으며 해당 구성 라인을 수정하지 않고도 해당 동작을 제한할 수 있으므로 괜찮습니다(나중에 자세히 설명).
PrintMotd
PrintMotd
사용자가 대화형으로 로그인할 때 sshd(8)
인쇄할지 여부를 지정합니다 . /etc/motd
(일부 시스템에서는 쉘, /etc/profile 또는 이에 상응하는 명령으로도 인쇄됩니다.) 기본값은 입니다 yes
.
PrintMotd <anything>
구성 파일 에 이 항목이 없을 수도 있으므로 sshd_config
기본값은 항상 오늘의 메시지를 표시하는 것입니다.
블록 설정
문제를 해결하기 위해 이 SFTP/SCP 활동의 사용자 이름이 이라고 가정하겠습니다 sftp
.
모든 sftp
사용자가 배너나 오늘의 메시지(MotD)를 볼 수 없도록 붙여넣고 사용하는 설정 블록은 다음과 같습니다.
Match User sftp
Banner none
PrintMotd no
설정 배치
위 설정 블록은 다음 파일 이름 중 하나로 들어갈 수 있습니다.
/etc/ssh/sshd_config
(OpenSSH v7.3 이하를 사용하는 이전 배포판, 최대macOS
12 몬트레이버전)/etc/ssh/sshd_config.d/900-custom-match-sftp.conf
(2016년 이후 OpenSSH v7.3부터)
드물다: 가능성은 높지 않지만(시스템 관리자가 복잡하거나 기업 환경이 아닌 이상) 위의 설정 블록은 , 또는 블록 Match user sftp
앞에 배치하고 읽어야 합니다 .Match all
Match canonical
Match final
참고: 다중 파일 SSH 서버 구성은 /etc/ssh/sshd_config.d
ASCII 순서로 로드됩니다. 다중 파일 구성 접근 방식에서는 적절한 읽기 순서를 보장하기 위해 시작 파일 이름으로 2자리 또는 3자리 숫자를 사용하는 것이 일반적입니다. 설정 블록은 , 또는 Match user
앞에 배치되어야 하므로 숫자는 or 앞에 위치 하며 다른 // 설정 블록 에서 사용됩니다 .Match all
Match canonical
Match final
970-*
97-*
9[7-9]-*
9[7-9][0-9]-*
canonical
final
all
SSH 서버 다시 로드/다시 시작
그런 다음 SSH 서버를 다시 로드/다시 시작하십시오.
다음 번 scp
로그인 sftp
시도 시 더 이상 오늘의 배너나 메시지가 표시되지 않습니다.
답변2
이 옵션을 시도해 보셨습니까? -o LogLevel=quiet