有没有人知道ssh -i相当于sshfs? 我想使用sshfs而不要求input密码
最好的解决scheme是Zoredachebuild议的ssh-agent 。
另一种方法是把你的密钥放在~/.ssh/id_rsa ,这样会自动检测到。 (为DSA密钥使用id_dsa 。)
还有一个是~/.ssh/config 。 把这样的东西放在里面(更多细节请参见ssh_config手册页)
主机somebox.somedomain.tld 用户joe IdentityFile〜/ key_for_somebox 主机* IdentityFile〜/ key_for_everything_else
设置您的系统使用SSH代理并将您的密钥添加到代理。 如果您正在使用最新的Linux发行版(例如Ubuntu和其他),则可能已经为您设置了ssh-agent。 所有你需要inputssh-add key 。
另一个答案是sshfs -o IdentityFile=/home/me/.ssh/somekey.pem user@host:/path/ mnt/
另外,你会看到人们列出了唤起sshfs的另一种方法:
sshfs -o ssh_command="ssh -i /home/me/.ssh/somekey.pem" user@host:/path/ mnt/
虽然我会同意~/.ssh/config是要走的路。
不是你所要求的,但是为了其他人试图连接到不支持密钥authentication的服务器的好处,你可以使用sshpass为你input你的密码,即使使用sshfs 。
例如,如果你在/etc/fstab类似的东西:
sshfs#username@host:/ /mnt/here fuse auto,ssh_command=sshpass\040-f\040/root/.ssh/host.password\040ssh 0 0
然后将密码放在/etc/fstab指定的文件名中:
echo 'secret' > /root/.ssh/host.password
确保你已经安装了sshpass :
pacman -S sshpass # if you're using Arch Linux
那么它应该工作:
mount /mnt/here
您可能需要首先ssh到服务器确认其密钥,但在此之后,这应该没有手动交互。