apache는
su - apache
로 유저 변경 불가.
( 기본쉘이 /sbin/nologin 로 지정되어있어서)
# cat /etc/passwd|grep apache
apache:x:??:??:Apache:/usr/share/httpd:/sbin/nologin
테스트를 위해서는
# sudo -u apache ssh ~~~~~~~
처럼 명령어 sudo 를 이용.
# sudo -u apache ssh {USER}@127.0.0.1
Could not create directory '/usr/share/httpd/.ssh'.
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:K?????????X5K5mXX2???????+EDPZeM.
ECDSA key fingerprint is MD5:??:d5:??:f4:??:??:??:70:??:??:5c:de:22:a3:60:ec.
Are you sure you want to continue connecting (yes/no)?
위 처럼 메세지가 나오는데, apache 웹 환경에서는 저런 메세지도 안보인다.
* 처리방법 1 : apache 계정으로 ssh 동작 가능하도록 수정
( /usr/share/httpd/ 가 apache의 homedir 인 경우)
# mkdir /usr/share/httpd/.ssh
# chown apache:apache /usr/share/httpd/.ssh
# chmod 700 /usr/share/httpd/.ssh
위 작업 후 최초 테스트로 접속해서 yes 를 해주면 이후 같은 host에 대해서 "Are you sure you want to continue connecting (yes/no)?"를 안 물어 봄
* 처리방법 2 : 질문 안 하도록 옵션추가
# sudo -u apache ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {USER}@127.0.0.1
Could not create directory '/usr/share/httpd/.ssh'. <-- 이건 stderr
Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts. <-- 이건 stderr
{USER}@127.0.0.1's password:
* ssh 비번을 입력하는 이슈가 있으니깐 웹에서 실행할 경우
-i {privatekey경로}
추가해서 비번 입력 없이 진행하자.