How to Access Git Repository via SSH

来源:互联网 发布:淘宝助理有什么好处 编辑:程序博客网 时间:2024/06/01 09:29

Example

Condition

There is a connection between ssh client and ssh server;

ssh testuser@testsshd.example.net

Config

Create a config in ~/.ssh/

cd ~cd .sshvim config... ...cat config

Contents of ~/.ssh/config

Host    testsshd    HostName testsshd.exmple.net    User     testuser    IdentityFile ~/.ssh/keys/testuser.private.rsakeyHost    OtherAlias    HostName other.example.net    User     otheruser    IdentityFile ~/.ssh/keys/otheruser.private.rsakey

remeber to chmod rsakey less access:

chomd 600 ~/.ssh/keys/testuser.private.rsakey

Test Connection via config

ssh -v testsshd... balabala ...<Connection OK>
Git Clone via SSH
git clone ssh://testsshd/~/website.git
Syntax
  • git clone [protocol]://[alias]/[path]
0 0