前几天在服务器上配置了git。
服务器重新搭建环境之后,还是经常遭到攻击,只是不那么频繁。
服务器安全这方面我懂得不多。
没什么能做的,就关闭了SSH默认的22端口,换成了其他。
当然。今天的重点不是说他,修改端口成功之后。登录好用。
寻思从git上下载一下代码,唉我去……报错。
fatal: Not a git repository (or any of the parent directories): .git
初始代本地版本库:
[root@NB gitdb]# git init
Initialized empty Git repository in /data/gitdb/.git/
发生下面的报错:
git pull git@xx.xxx.xx.xx:yanjing_chenl/IT-DOC.git
ssh: connect to host xx.xx.xx.xx port 22: Connection timed out
fatal: The remote end hung up unexpectedly
因为我修改了linux服务器的SSH端口为非22端口
ssh默认端口为22,而Git的访问是基于ssh的。为了安全我们会更改服务的ssh端口号,即当ssh的端口不是22端口时,git访问会出现:
ssh: connect to host xxx.com port 22: Connection timed out
嘿……这可如何是好。
百度找到的一些方法基本上是修改配置文件之类的。
讲真,这个我看不懂……
寻思半天,我就想,我在克隆代码的时候,直接把ssh的端口号加在ip后边不就好了么
试了一下还真好用……
好用的示例:
git clone ssh://git@192.168.1.111:2222/root/test.git
注意:链接中的 ssh:// 一定不要忘记了。
有好的建议,请在下方输入你的评论。