Android-Studio git 通过 ssh
Android-Studio git over ssh
我的 Raspberry Pi 上有一个 git 服务器,使用 gitweb 作为网络界面。
到目前为止它的工作。
现在我想通过 Android Studio 使用内置的 ssh 连接到它。
我的项目目录是:
/home/git/straff.git
我将从 Android Studio 使用此命令连接:
:ssh:git@192.168.178.21:/straff
Android Studio 在我测试连接时给我这个:
Cannot access /straff/CVSROOT
我正在使用密码验证。我可以从命令行工具访问我的存储库...
为什么 Android Studio 不能?
I can access from command line tools to my repo...
Why Android Studio cant?
您的错误是您正在尝试访问 192.168.178.21:/straff,这是该机器上的 /straff。要么像下面那样提供完整路径,要么使用这个
:ssh:git@192.168.178.21:straff
旧 post:
您可以尝试指定 Android Studio 的完整路径:
:ssh:git@192.168.178.21:/home/git/straff
I am using password auth for it.
这意味着 ssh 连接不使用 private/public (~/.ssh/id_rsa(.pub)
) 密钥。
AndroidStudio 的一个很好的教程是标题为“How to push to a remote Git repository over SSH with private/public key authentication using Android Studio”的教程。
嗯,URL 应该是这样的:
ssh://git@192.168.178.21/straff
我在设置 ssh 密钥时遇到了问题。我通过在 .ssh-directory 下(在用户 home-dir 下)创建 id_rsa 标题文件并将我的 RSA-stuff 放入其中来解决它。
如果您已经拥有要检出的远程 git 存储库,并且您有一个私钥,那么 https://www.londonappdeveloper.com/how-to-push-to-a-remote-git-repository-over-ssh-with-privatepublic-key-authentication-using-android-studio/ 上的说明可能会在一定程度上有所帮助,但它们是对于旧版本的 Android Studio,它们太复杂了。
您需要做的(尤其是当您从头开始时)是:
确保您的密钥是 OpenSSH 密钥,并且是私钥(而不是 public 密钥)。这就是上述说明具有误导性的地方 - 它们指向所谓的 Putty 格式(.ppk 文件)的密钥,而这不起作用。如果您有 Putty 密钥,请使用 Putty 的 puttygen.exe 工具以 OpenSSH 格式导出私钥。
按照这些说明中的说明创建 config
文件。 IE。
- 在用户目录的
.ssh
子目录中创建名为 config
的文本文件。在我的例子中,路径是 C:\Users\Eugene.ssh\config.
- 将以下内容放入此文件:
Host my-host.com
HostName my-host.com
Port 22
IdentityFile C:\Users\Eugene.ssh\my-private-key-for-my-host.openssh
(原始说明包括第 2-4 行的缩进,但我无法在此处添加任何缩进)。
- 使用 Android Studio 欢迎屏幕中的
Checkout Project From Version Control
菜单项启动 GIT 结帐。
- 在结帐时使用以下设置(大括号包含您替换为您的值):
Git Repository URL: {projectalias}@{my-host.com}:base/{projectname}
Parent directory: eg. "z:\Projects" The path which must exist, and in which the new project is created
Project directory: eg. "myproject". The directory with this name will be created in Parent directory, so the files will be checked out to Parent_directory\Project_directory, eg. "z:\Projects\myproject".
我的 Raspberry Pi 上有一个 git 服务器,使用 gitweb 作为网络界面。
到目前为止它的工作。
现在我想通过 Android Studio 使用内置的 ssh 连接到它。
我的项目目录是:
/home/git/straff.git
我将从 Android Studio 使用此命令连接:
:ssh:git@192.168.178.21:/straff
Android Studio 在我测试连接时给我这个:
Cannot access /straff/CVSROOT
我正在使用密码验证。我可以从命令行工具访问我的存储库...
为什么 Android Studio 不能?
I can access from command line tools to my repo...
Why Android Studio cant?
您的错误是您正在尝试访问 192.168.178.21:/straff,这是该机器上的 /straff。要么像下面那样提供完整路径,要么使用这个
:ssh:git@192.168.178.21:straff
旧 post:
您可以尝试指定 Android Studio 的完整路径:
:ssh:git@192.168.178.21:/home/git/straff
I am using password auth for it.
这意味着 ssh 连接不使用 private/public (~/.ssh/id_rsa(.pub)
) 密钥。
AndroidStudio 的一个很好的教程是标题为“How to push to a remote Git repository over SSH with private/public key authentication using Android Studio”的教程。
嗯,URL 应该是这样的: ssh://git@192.168.178.21/straff
我在设置 ssh 密钥时遇到了问题。我通过在 .ssh-directory 下(在用户 home-dir 下)创建 id_rsa 标题文件并将我的 RSA-stuff 放入其中来解决它。
如果您已经拥有要检出的远程 git 存储库,并且您有一个私钥,那么 https://www.londonappdeveloper.com/how-to-push-to-a-remote-git-repository-over-ssh-with-privatepublic-key-authentication-using-android-studio/ 上的说明可能会在一定程度上有所帮助,但它们是对于旧版本的 Android Studio,它们太复杂了。
您需要做的(尤其是当您从头开始时)是:
确保您的密钥是 OpenSSH 密钥,并且是私钥(而不是 public 密钥)。这就是上述说明具有误导性的地方 - 它们指向所谓的 Putty 格式(.ppk 文件)的密钥,而这不起作用。如果您有 Putty 密钥,请使用 Putty 的 puttygen.exe 工具以 OpenSSH 格式导出私钥。
按照这些说明中的说明创建
config
文件。 IE。- 在用户目录的
.ssh
子目录中创建名为config
的文本文件。在我的例子中,路径是 C:\Users\Eugene.ssh\config. - 将以下内容放入此文件:
- 在用户目录的
Host my-host.com
HostName my-host.com
Port 22
IdentityFile C:\Users\Eugene.ssh\my-private-key-for-my-host.openssh
(原始说明包括第 2-4 行的缩进,但我无法在此处添加任何缩进)。
- 使用 Android Studio 欢迎屏幕中的
Checkout Project From Version Control
菜单项启动 GIT 结帐。 - 在结帐时使用以下设置(大括号包含您替换为您的值):
Git Repository URL: {projectalias}@{my-host.com}:base/{projectname}
Parent directory: eg. "z:\Projects" The path which must exist, and in which the new project is created
Project directory: eg. "myproject". The directory with this name will be created in Parent directory, so the files will be checked out to Parent_directory\Project_directory, eg. "z:\Projects\myproject".