Linux

從 fstab 掛載 SSHFS 無法進行身份驗證

  • September 25, 2020

我創建了 SSH 密鑰並使用ssh-copy-id將其傳輸到我的目標設備,現在我可以ssh targetUsername@targetHost -p 8798不提供 RSA 密鑰或targetUsername@targetHost的密碼,但是當我嘗試在fstab中掛載 SSHFS 共享時(結尾是出於調試目的

sshfs#targetUsername@targetHost:/mnt /media/omnia2 fuse.sshfs _netdev,defaults,IdentityFile=/home/localUsername/.ssh/id_rsa,idmap=user,port=8798,ssh_command=ssh\040-vv,sshfs_debug,debug 0 0

即使我提供了一個好的密碼,也會要求並拒絕targetUsername@targetHost的密碼。Permission denied, please try again令我驚訝的是如何刪除 RSA 密鑰身份驗證:

debug2: pubkey_prepare: done
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/localUsername/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
sshfs#targetUsername@targetHost's password:

我想我已經清除了所有本地權限。我的另一個嘗試是/root/.ssh/id_rsa用於密鑰儲存,但這並沒有改變任何事情。

通過檢查journalctl -u ssh.service目標機器,我意識到目標主機sshfs#targetUsername從 fstab 條目中辨識為使用者名,而我的意圖是登錄targetUsernamesshfs#從 fstab 條目中刪除解決了該問題。

引用自:https://serverfault.com/questions/1035374