简体   繁体   English

如何使用sshfs autshount从mac到ubuntu的ssh密钥

[英]How to use ssh keys for sshfs automount from mac to ubuntu

I want to be able to automount an ubuntu volume on my mac using sshfs. 我希望能够使用sshfs在我的mac上自动挂载ubuntu卷。 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. 我尝试使用ssh key-gen并复制id_rsa文件,使用各种sshfs -o选项将pub键添加到我的授权密钥,但无济于事。

The procedure for setting up ssh key authentication is the same whether you are using it for sshfs or something else. 无论是将其用于sshfs还是其他用户,设置ssh密钥身份验证的过程都是相同的。

On the client side you generate a key. 在客户端,您生成一个密钥。 In this case we are making a DSA key 在这种情况下,我们正在制作DSA密钥

ssh-keygen -t dsa

You should now have an id_dsa file and an id_dsa.pub file in your .ssh directory. 您现在应该在.ssh目录中有一个id_dsa文件和一个id_dsa.pub文件。 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. pub文件是您的公钥,其内容将放置在您要登录的服务器的.ssh目录中的authorized_keys文件(如果您使用上述DSA密钥,则为authorized_keys2)。

If you are on a Linux client, you can probably push the key to the server using the ssh-copy-id command. 如果您使用的是Linux客户端,则可以使用ssh-copy-id命令将密钥推送到服务器。

ssh-copy-id user@server:

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. 在客户端,id_dsa文件需要由您拥有并具有600个权限,这是生成密钥时的默认权限。 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. 在服务器端,authorized_keys文件需要由您拥有,而不是全局可写的,如果您在复制它时不做任何奇怪的操作,就像以root身份执行一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM