如何使用 ssh 密钥从 mac 到 ubuntu 进行 sshfs 自动挂载
我希望能够使用 sshfs 在我的 Mac 上自动挂载 ubuntu 卷。我尝试使用 ssh key-gen 并复制 id_rsa 文件,将 pub 密钥添加到我的授权密钥中,使用各种 sshfs -o 选项,但无济于事。
I want to be able to automount an ubuntu volume on my mac using sshfs. I tried using ssh key-gen and copying the id_rsa file, adding the pub key to my authorized keys, using all sorts of sshfs -o options, to no avail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无论您将其用于 sshfs 还是其他用途,设置 ssh 密钥身份验证的过程都是相同的。
在客户端您生成一个密钥。在本例中,我们正在制作 DSA 密钥。
您的 .ssh 目录中现在应该有一个 id_dsa 文件和一个 id_dsa.pub 文件。 pub 文件是您的公钥,其内容放置在您要登录的服务器的 .ssh 目录中的authorized_keys 文件(如果您使用上述 DSA 密钥,则为authorized_keys2)
。对于 Linux 客户端,您可以使用 ssh-copy-id 命令将密钥推送到服务器。
在客户端,id_dsa 文件需要由您拥有并具有 600 权限,这是生成密钥时的默认值。在服务器端,authorized_keys 文件需要由您拥有,并且不可全局写入,如果您在复制它时不做任何奇怪的事情(例如以 root 身份执行此操作),则应该是这种情况。
The procedure for setting up ssh key authentication is the same whether you are using it for sshfs or something else.
On the client side you generate a key. In this case we are making a DSA key
You should now have an id_dsa file and an id_dsa.pub file in your .ssh directory. The pub file is your public key, and its contents get placed inside the authorized_keys file (or authorized_keys2 if you are using a DSA key as above) in the .ssh directory of the server to which you want to log in.
If you are on a Linux client, you can probably push the key to the server using the ssh-copy-id command.
On the client side the id_dsa file needs to be owned by you and have 600 permissions, which is the default when you generate the key. On the server side the authorized_keys file needs to be owned by you and not be world writable, which should be the case if you don't do anything weird when copying it over like doing that as root.