git安装 perl ubuntu_ubuntu下安装git

本文介绍了如何在Ubuntu 16.04系统上安装Git,通过apt-get命令进行安装,并配置用户信息。接着,文章详细讲解了生成SSH公钥并将其添加到GitHub账户的过程,以便将Linux服务器与GitHub账户关联,实现项目的便捷管理。
摘要由CSDN通过智能技术生成

最近在做自己的个人博客项目,部署在阿里云主机上,系统为ubuntu 16.04.4。项目开发在自己的Windows电脑上,每次项目进行改动后都需要手动上传文件到服务器上,感觉很是麻烦。所以准备在服务器上安装git并关联github账号,通过github进行中转,拉取上面的项目信息,希望能够简便项目变更所带来的麻烦。

连接远程主机使用的工具是 Xshell

一、安装git

首先输入git命令查看git是否已经安装

root@wangjun:~# git

The program 'git' is currently not installed. You can install it by typing:

apt install git

系统提示git未安装,并提示安装方式,依照上面的提示输入命令:

root@wangjun:~# apt install git

注意:这里使用的安装方式是安装方式,也可以使用源码安装等其他的方式,这里就不在介绍。

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following packages were automatically installed and are no longer required:

linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-image-4.4.0-87-generic

linux-image-extra-4.4.0-87-generic

Use 'apt autoremove' to remove them.

The following additional packages will be installed:

git-man liberror-perl

Suggested packages:

git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch git-cvs git-mediawiki

git-svn

The following NEW packages will be installed:

git git-man liberror-perl

0 upgraded, 3 newly installed, 0 to remove and 109 not upgraded.

Need to get 3,914 kB of archives.

After this operation, 25.6 MB of additional disk space will be used.

Do you want to continue? [Y/n] y

Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 liberror-perl all 0.17-1.2 [19.6 kB]

Get:2 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 git-man all 1:2.7.4-0ubuntu1.4 [736 kB]

Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 git amd64 1:2.7.4-0ubuntu1.4 [3,158 kB]

Fetched 3,914 kB in 0s (29.3 MB/s)

Selecting previously unselected package liberror-perl.

(Reading database ... 185354 files and directories currently installed.)

Preparing to unpack .../liberror-perl_0.17-1.2_all.deb ...

Unpacking liberror-perl (0.17-1.2) ...

Selecting previously unselected package git-man.

Preparing to unpack .../git-man_1%3a2.7.4-0ubuntu1.4_all.deb ...

Unpacking git-man (1:2.7.4-0ubuntu1.4) ...

Selecting previously unselected package git.

Preparing to unpack .../git_1%3a2.7.4-0ubuntu1.4_amd64.deb ...

Unpacking git (1:2.7.4-0ubuntu1.4) ...

Processing triggers for man-db (2.7.5-1) ...

Setting up liberror-perl (0.17-1.2) ...

Setting up git-man (1:2.7.4-0ubuntu1.4) ...

Setting up git (1:2.7.4-0ubuntu1.4) ...

root@wangjun:~#

一大串信息,看着很爽,注意没报错信息安装就完成了。

可以在命令行输入git,会提示git命令

root@wangjun:~# git

usage: git [--version] [--help] [-C ] [-c name=value]

[--exec-path[=]] [--html-path] [--man-path] [--info-path]

[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]

[--git-dir=] [--work-tree=] [--namespace=]

[]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)

clone Clone a repository into a new directory

init Create an empty Git repository or reinitialize an existing one

git命令有很多,有时间可以仔细看一下。

二、进行git配置

后面的步骤其实和在Windows上配置git基本相同。

不过Windows上可以使用git bash进行命令的执行,或者使用图形化工具进行处理。喜欢的话也可以在Windows的命令行中执行命令,哈哈哈

这里就直接在linux命令行中输入git命令就行了。

root@wangjun:~# git config --global user.name '自定义用户名'

root@wangjun:~# git config --global user.email '邮箱'

这样的话,git最基本的配置就完成了,虽说是最基本的,不过对于我们来说已经够用了,接下来就可以像在Windows上同样使用了。

三、连接github

接下来就是最后一步也就是最重要的一步了。

1.生成公钥

命令行执行生成公钥命令

root@wangjun:~# ssh-keygen -C '邮箱' -t rsa

这里的邮箱是刚才配置里的邮箱,生成的公钥文件保存在当前路径下,当然你可以指定任意保存路径。

接下来会提示输入保存公钥的文件名称,以及文件打开密码。这里的密码可以不填,默认为空。不过建议为了安全可以设置一个密码,公钥文件请妥善保存,以免遗失。

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): publickey

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in publickey.

Your public key has been saved in publickey.pub.

The key fingerprint is:

SHA256:这里是指纹信息

The key's randomart image is:

+---[RSA 2048]----+

| oo +BO|

| .. =.+O|

| ..o++o.|

| = =.oo.|

| .S.+ o. .|

| +=. . . |

| E + ...o .|

| ...+o.= . o.|

| 哈哈很有趣的图片

+----[SHA256]-----+

上面的信息都是很有用的,请妥善保存。

2.连接github

进入github网站,打开setting,选择SSH and GPG key 条目:

然后

在这里添加刚才保存的公钥信息

打开保存公钥的文件,复制里面的信息粘贴到上面的添加公钥的地方,然后提交就行了。

root@wangjun:~# cat publickey.pub

ssh-rsa AAAAB3NzaC1yc2EAAc2ps3Yy4/a这里的一大串就是公钥信息UzcH7DFBVFlgE4X3v5BH/adtRYabiFKW5sewf0n+75kz3Q6YBu1DiPOEmwpoSmPBEoLGBJCmiydkjdop0pfjn2dGYv 1273477277@qq.com

root@wangjun:~#

到此,任务就基本完成了,可以试着在github上克隆一个项目试试

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值