Windows 上的 SourceTree:如何连接到 SSH? [英] SourceTree on Windows: How to connect to SSH?

查看:73
本文介绍了Windows 上的 SourceTree:如何连接到 SSH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过 SSH 访问我的虚拟主机,它与 PuTTY 配合得很好(我只需要输入我的域、用户名和密码),但是使用 SourceTree 似乎要复杂得多.

I have an SSH access to my web hosting, it works great with PuTTY (I just had to enter my domain, username and password), however it seems much more complicated with SourceTree.

虽然 PuTTY 有一个字段用于主机名"、用户名"和密码",但 SourceTree 没有并且需要一个特殊文件.ppk"?!

While PuTTY has a field for "Host Name", "username" and "password", SourceTree doesn't and requires a special file ".ppk"?!

我需要通过 SSH 将 SourceTree 连接到我的虚拟主机,原因很明显,我想用它来推送到位于我的虚拟主机上的远程存储库.

I need to connect SourceTree to my web hosting via SSH for the obvious reason that I want to use it to push to a remote repository located on my web hosting.

那么如何获得从我的域/用户名/密码生成的 .ppk 文件?非常感谢任何帮助!

So how do I get a .ppk file generated from my domain/username/password? Any help greatly appreciated!

PS:我注意到他们通过提供两个简单的字段:用户名"和密码",使连接到 BitBucket 变得异常容易,并使连接到第三方 SSH 变得异常困难... 是故意阻止竞争吗?!

推荐答案

有两种方法可以将 SourceTree 连接到任何 SSH.

There are two ways to connect SourceTree to any SSH.

最简单的方法是使用您的虚拟主机提供商提供的域名、用户名和密码:

只需使用以下语法:ssh://username@example.com/ – SourceTree 将在您推送到该 SSH 时提示您输入密码:

Simply use the following syntax: ssh://username@example.com/ – SourceTree will then prompt you to enter your password whenever you push to that SSH:

如果您选中记住密码复选框,您的密码将被保存并且不会再次提示您输入密码.您可以稍后通过转到 Tools > 来编辑或删除存储的密码.选项 >身份验证如下图所示:

If you check the Remember password checkbox, your password will be saved and you will not be prompted again for it. You can edit or remove the stored password at a later time by going to Tools > Options > Authentication as shown on the image below:

注意:就我而言(1&1 共享主机),用户名和密码都与我的主 FTP 帐户相同.

Note: In my case (1&1 Shared Hosting), the username and password were both the same as my main FTP account.

更复杂的方法是使用私钥/公钥对:

这意味着使用PuTTY Key Generator"生成两个密钥(一个私有"和一个公共")(在 SourceTree 中转到 Tools > Create or Import SSH Keys).

This implies generating two keys (one "private" and one "public") using the "PuTTY Key Generator" (in SourceTree go to Tools > Create or Import SSH Keys).

生成后,将私钥保存到 .ppk 文件并加载到 SourceTree 中(Tools > Create or Import SSH Keys > Load).它还没有结束:现在您必须将公钥添加到您的服务器.为此,请将其添加到 Web 服务器上的以下文件中:/.ssh/authorized_keys.

Once generated, save the private key to a .ppk file and load it in SourceTree (Tools > Create or Import SSH Keys > Load). It's not over yet: now you must add the public key to your server. To do that, add it to the following file on your web server: /.ssh/authorized_keys.

如果此文件不存在,请将您的公钥保存到名为 authorized_keys 的文件中,然后通过 FTP 将其上传到您的服务器.您必须将其上传到位于根目录下的名为 /.ssh/ 的目录中(如果它不存在,只需创建它).

If this file doesn't exist, save your public key to a file named authorized_keys and upload it to your server via FTP. You must upload it into a directory named /.ssh/ located at the root (if it doesn't exist, simply create it).

注意:确保使用您的主机帐户的 main FTP 帐户.如果它不起作用,请使用您的 FTP 软件调整 authorized_keys 文件的权限(chmod)并将其设置为 777(右键单击authorized_keys" > 文件权限):

Note: Make sure to use the main FTP account of your hosting account. If it doesn't work, adjust the permissions (chmod) of the authorized_keys file and set it to 777 using your FTP software (Right-click on "authorized_keys" > File permissions):

不需要任何命令行.

这篇关于Windows 上的 SourceTree:如何连接到 SSH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆