서버에 연결하고, 사용자가 로그인할 때 사용자의 홈 폴더를 마운트하고, 일정 기간 동안 활동이 없으면 마운트를 해제해야 합니다. 어떻게 하는지는 모르겠지만 ls /home
간단한 방법으로 알아냈습니다.
서버에 SSH로 접속할 때마다 비밀번호를 입력하지 않아도 되도록 키 쌍을 설정했습니다. 서버를
확인해 ~/.ssh/authorized_keys
보니 키가 정확합니다.
그 후에는 ssh-copy-id
잘 작동했지만 다음 날 비밀번호를 묻는 메시지가 나타났습니다. 당일, 다음 로그인 시 즉시 사용 가능한 키를 사용할 수 있습니다.
그래서 가끔 키가 작동하지 않는 이유는 홈 폴더(등 ~/.ssh/authorized_keys
)이 아직 마운트되지 않았기 때문이라고 추측합니다.
시도해 보았지만 cat
/etc/ssh/sshd_config
읽기 권한도 없습니다.
가능한 해결책을 추측할 수 없습니다.
첫 시도:
❯ ssh -v <username>@<host>
OpenSSH_9.0p1, OpenSSL 1.1.1q 5 Jul 2022
debug1: Reading configuration data /home/dpd-/.ssh/config
debug1: /home/dpd-/.ssh/config line 18: Applying options for <host>
debug1: /home/dpd-/.ssh/config line 41: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 5: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/run/user/1000/kssh-316772-62ebc2b2eab867050f1276d08a9eed0a7d94401d" does not exist
debug1: Connecting to <host> [<ip>] port 22.
debug1: Connection established.
debug1: identity file /home/dpd-/.ssh/DEI type 3
debug1: identity file /home/dpd-/.ssh/DEI-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.0
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.7
debug1: compat_banner: match: OpenSSH_8.7 pat OpenSSH* compat 0x04000000
debug1: Authenticating to <host>:22 as '<username>'
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:<hash>
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '<host>' is known and matches the ED25519 host key.
debug1: Found key in /home/dpd-/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: ssh_fetch_identitylist: agent contains no identities
debug1: Will attempt key: /home/dpd-/.ssh/DEI ED25519 SHA256:<hash> explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/dpd-/.ssh/DEI ED25519 SHA256:<hash> explicit
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: password
<username>@<host>'s password:
이후 시도:
❯ ssh -v <username>@<host>
debug1: multiplexing control connection
debug1: channel 1: new [mux-control]
debug1: channel 1: free: mux-control, nchannels 2
OpenSSH_9.0p1, OpenSSL 1.1.1q 5 Jul 2022
debug1: Reading configuration data /home/dpd-/.ssh/config
debug1: /home/dpd-/.ssh/config line 18: Applying options for <host>
debug1: /home/dpd-/.ssh/config line 41: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 5: Applying options for *
debug1: auto-mux: Trying existing master
debug1: multiplexing control connection
debug1: channel 1: new [mux-control]
debug1: channel 2: new [client-session]
if [ -z "$python" -o ython=$(command -v python))*" > /dev/stderr; cleanup_on_bootstrap_exit; exit 1; }4\\\\\\n\\\\\\041)"' '/bin/sh
debug1: mux_client_request_session: master session id: 2
no-rc enabled
$