![암호화된 홈 디렉토리 및 SSH(키 인증만)로 인해 X11 전달이 중단됨](https://linux55.com/image/95320/%EC%95%94%ED%98%B8%ED%99%94%EB%90%9C%20%ED%99%88%20%EB%94%94%EB%A0%89%ED%86%A0%EB%A6%AC%20%EB%B0%8F%20SSH(%ED%82%A4%20%EC%9D%B8%EC%A6%9D%EB%A7%8C)%EB%A1%9C%20%EC%9D%B8%ED%95%B4%20X11%20%EC%A0%84%EB%8B%AC%EC%9D%B4%20%EC%A4%91%EB%8B%A8%EB%90%A8.png)
Ubuntu 16.04를 설치할 때 홈 디렉토리를 암호화하기로 결정했습니다. 보안상의 이유로 비밀번호 로그인이 비활성화되어 있기 때문에 SSH 키 인증만 사용합니다.
다음을 사용하여 ".ssh/authorized_keys 때문에 로그인할 수 없습니다" 문제를 해결할 수 있었습니다.https://stephen.rees-carter.net/thought/encrypted-home-directories-ssh-key-authentication. 간단히 말해서:
sudo vim ~/.profile
그런 다음 입력
ecryptfs-mount-private
cd /home/username
그러나 이제 SSH를 통한 X11 전달이 중단되었습니다. MMC(MIT Magic Cookie) .Xauthority 파일이 암호화되지 않은 홈 디렉터리로 이동하지 않는 것 같습니다.
답변1
내 초기 아이디어는 ~/.profile을 다음과 같이 수정하는 것이었습니다.
cp "$HOME/.Xauthority" /temp/$USERNAME/
ecryptfs-mount-private
mv /temp/$USERNAME/.Xauthority "$HOME"
그 중 /temp/$USERNAME은 $USERNAME이 소유한 디렉토리로 700개의 권한을 가지고 있습니다. 하지만 이 옵션이 얼마나 안전한지는 잘 모르겠습니다.
답변2
나는 이것을 내 것으로 사용하고 있습니다 /usr/local/bin/ecryptfs-mount-private
.
#!/bin/sh
# eCryptfs helper script that transfers X11 Authority properly after mounting
# Copyright 2016+ by Adam Katz <https://github.com/adamhotep>, GPLv2+
# If you're root or lack the expected ecryptfs area, don't do anything extra
if [ "$(id -u)" = 0 ] || ! [ -d "/home/.ecryptfs/$USER" ]; then
exec /usr/bin/ecryptfs-mount-private "$@"
exit $?
fi
if grep -qs "$HOME/.Private $HOME ecryptfs" /proc/mounts; then
exit # already mounted
fi
xauth="$(base64 $HOME/.Xauthority)"
if /usr/bin/ecryptfs-mount-private "$@"; then
echo "$xauth" |base64 -d |xauth merge
fi
이는 SSH에 의해 추가된 인증을 포함하여 암호화된 집의 xauth를 암호화되지 않은 집의 xauth와 안전하게 병합합니다. 이는 여러 호스트에서 동시에 연결할 때 중요합니다(암호화를 재정의하면 ~/.Xauthority
암호화된 홈 디렉토리가 설치될 때 생성된 세션에 대한 인증이 취소됩니다).
base64
바이너리 데이터를 변수에 안전하게 저장할 수 있는 데이터로 변환하는 데 사용됩니다 .