我可以在 PuTTy(在 Mac 上)以外的其他应用程序中使用 SSH 密钥吗?

发布于 2024-07-14 02:04:53 字数 109 浏览 3 评论 0原文

Bluehost 仅推荐 PuTTy。 但是,是否可以在 Mac 中使用 ssh 密钥而无需任何额外的可见程序?

我希望能够轻松连接到我的服务器,以便我可以在终端中控制我的服务器。

Bluehost only recommends PuTTy. However, is it possible to use ssh keys without any extra, visible programs in Mac?

I would like to have a connection to my server to be a breeze, so that I can control my server in Terminal.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

绮筵 2024-07-21 02:04:53

当然! 在 Unix 和 OS X 上,ssh-keygen 命令将为 SSH 公钥身份验证生成公钥和私钥。 调用此命令(在客户端)的常用方法是:

ssh-keygen -t rsa

此命令将询问您将私钥放在哪里; 默认位置为~/.ssh/id_rsa,公钥将放置在添加.pub扩展名的同名文件中(例如:<代码>~/.ssh/id_rsa.pub)。 该命令还要求您为私钥创建密码(“passphrase”); 你可以像我一样将其留空,不设置密码,但我不推荐这种做法。

在客户端计算机上拥有公钥和私钥后,您需要使服务器识别该公钥。 如果您有服务器的 shell 访问权限,则可以使用 scp 上传公钥文件,然后使用 ssh 在服务器上运行以下命令:

cat id_rsa.pub >> ~/.ssh/authorized_keys 

如果您的托管公司没有不会为您提供 shell 访问权限(尽管 Bluehost 提供),或者此过程不起作用,但它可能会为您提供具有相同功能的 Web 界面。

一旦您的服务器设置为识别您的公钥,当客户端上的 ssh 尝试使用您的私钥进行身份验证时,它将允许您无需密码即可访问。 您可能仍需要输入私钥的密码,但通常只需为每个客户端登录会话执行一次此操作。

Of course! On Unix and OS X, the ssh-keygen command will generate public and private keys for SSH public-key authentication. The usual way to invoke this command (on the client) is:

ssh-keygen -t rsa

This command will ask you where to place your private key; the default place is ~/.ssh/id_rsa, and the public key will be placed in the file of the same name with a .pub extension added (for example: ~/.ssh/id_rsa.pub). The command also asks you to create a password ("passphrase") for the private key; you can leave it blank for no password as I do, but I don't recommend this practice.

Once you have your public and private keys on the client computer, you need to make your server recognize that public key. If you have shell access to the server, you can upload the public key file with scp, then use ssh to run the following command on the server:

cat id_rsa.pub >> ~/.ssh/authorized_keys 

If your hosting company doesn't give you shell access (though Bluehost does), or this procedure doesn't work, it will likely give you a web interface to the same functionality.

Once your server is set up to recognize your public key, it will allow you access without a password when ssh on the client tries to use your private key for authentication. You may still have to enter your private key's password, but typically you only need to do this once for each client login session.

Oo萌小芽oO 2024-07-21 02:04:53

当然,我一直这样做。 只需按照这些说明生成 SSH 密钥并将其复制到您的服务器即可。 这些说明应该适用于 Mac 和 Linux。

Sure, I do this all the time. Just follow these directions to generate an SSH key and copy it to your server. The instructions should work on both Mac and Linux.

朦胧时间 2024-07-21 02:04:53

SSHKeychain 非常适合此目的。 它低调地位于菜单栏上,并与 OS X 的钥匙串和 SSH 实现无缝集成。

您将需要使用其他答案中所述的 ssh-keygen ,但是一旦完成,您就可以使用 SSHKeychain 来避免一直输入私钥密码。

SSHKeychain is pretty much ideal for this. It lives unobtrusively on the menu bar and integrates seamlessly with OS X's Keychain and SSH implementations.

You will need to use ssh-keygen as described in other answers, but once you've done that you can use SSHKeychain to avoid having to type your private key passphrase all the time.

OpenSSH 应该可以在 OS X 上使用; 打开终端并查看“man ssh”。 SSH 密钥存储在 ~/.ssh 中(以与 PuTTY 不同的格式)。 在 ~/.ssh/config 中进行配置也可以让您的生活更轻松; 您可以说“使用此 $KEY 将此 $SHORTNAME 用于此 $HOST”之类的内容。

OpenSSH should be available to you on OS X; open a terminal and check out "man ssh". SSH keys get stored (in a format different from PuTTY) in ~/.ssh. Having a config in ~/.ssh/config can make your life easier, too; you'll be able to say "Use this $SHORTNAME for this $HOST using this $KEY" and similar.

倦话 2024-07-21 02:04:53

在终端提示符 do

$ apropos ssh

您应该获得 Mac OS X 附带的与 ssh 相关的所有程序的列表。

使用 ssh* 工具,您的 ssh 密钥将存储在 ~/.ssh 下。 PuTTY 很不错,但与标准的 OpenSSH 工具相比,它实际上只在 Windows 系统上有用。

At the terminal prompt do

$ apropos ssh

You should get a list of all the programs Mac OS X comes with related to ssh.

Using the ssh* tools, your ssh keys will be stored under ~/.ssh. PuTTY is nice, but compared to the standard OpenSSH tools, it's really only useful on Windows systems.

橘虞初梦 2024-07-21 02:04:53

当然可以! 第一次运行:

ssh-keygen

并完成这些步骤。 给它一个密码等是个好主意。 然后您可以:

cat ~/.ssh/id_rsa.pub

将结果复制粘贴到 bluehost 公钥文本区域中。

Sure can! First run:

ssh-keygen

And go through the steps. It is a good idea to give it a password and such. Then you can:

cat ~/.ssh/id_rsa.pub

and copy-paste the result into the bluehost public key textarea.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文