サーバーに接続し、ユーザーがログインしたときにユーザーのホームフォルダをマウントし、一定期間アクティビティがない場合はマウントを解除する必要があります。どうするかはわかりませんが、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
$