个人博客搭建002_电脑上迁移博客

本文最后更新于:2023年10月23日 上午

适用于重新安装系统或者迁移到另外一台电脑,需要重新配置环境。搭建环境:Linux-ubuntu,20.04.01,。win环境下还未尝试。

一、Linux系统上迁移

(一)备份文件复制到文件夹

需要实时更新备份文件,使用tar命令打包并压缩。

(二)安装升级必要的软件

软件包括:nvm\git\nodejs

1
Linux@Linux-ThinkCentre-E75:~/文档/blogs$ sudo apt install npm # 有时候因为版本不对报错,需要把nodejs升级到最新版本

1.产看node版本,没安装的请先安装;

1
Linux@Linux-ThinkCentre-E75:~/文档/blogs$ node -v

2.如果安装失败,或者版本低,安装nvm更新升级nodejs;

1
Linux@Linux-ThinkCentre-E75:~/文档/blogs$ nvm install 18.18.1  

3.安装node版本管理工具’nvm’;

1
2
Linux@Linux-ThinkCentre-E75:~/文档/blogs$ https://raw.githubusercontent.com/creationix/nvm/master/install.sh # 远程安装
Linux@Linux-ThinkCentre-E75:~/文档/blogs$ source ~/.profile # 更新应用

4.使用版本管理工具安装指定node或者升级到最新node版本;

1
Linux@Linux-ThinkCentre-E75:~/文档/blogs$  nvm install stable  (安装node最新版本)

5.安装hexo

1
2
Linux@Linux-ThinkCentre-E75:~/文档/blogs$ sudo npm install -g hexo

(三)通过ssh keys绑定gitee/github

1.生成密钥(回车三次)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Linux@Linux-ThinkCentre-E75:~/文档/blogs$ ssh-keygen -t ed25519 -C "bs0716@126.com"  
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/Linux/.ssh/id_ed25519):
Created directory '/home/Linux/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/Linux/.ssh/id_ed25519
Your public key has been saved in /home/Linux/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:w1pBqIn8XtBaNIQIEo/pTOjqJxssGiQH7REkRB4zNyA bs0716@126.com
The key's randomart image is:
+--[ED25519 256]--+
|E@++ o... |
|=**.o +. |
|=++.= .. |
|=oo.+ o.. |
|.=o.+ S |
|=. o .o . |
|+o ... |
|+o... |
|.o+ |
+----[SHA256]-----+
Linux@Linux-ThinkCentre-E75:~/文档/blogs$

在github中的命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Linux@Linux-Lenovo-XiaoXinPro-13API-2019:~$ ssh-keygen -t rsa -C 'Linuxdeepin007@gmail.com'
Generating public/private rsa key pair.
Enter file in which to save the key (/home/Linux/.ssh/id_rsa):
Created directory '/home/Linux/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/Linux/.ssh/id_rsa
Your public key has been saved in /home/Linux/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:raNP4f208L04TjXseVXc6pIXWUA4HJicIFhGyDQizK8 Linuxdeepin007@gmail.com
The key's randomart image is:
+---[RSA 3072]----+
|+ .oo== .o =.+o |
| + .+o . = + o.|
| . . =|
| . . .+.|
| . S . B .|
| E .+ = +.|
| = o = = .|
| o .*.* .|
| ... .*.o.|
+----[SHA256]-----+
Linux@Linux-Lenovo-XiaoXinPro-13API-2019:~$

2.通过查看 ~/.ssh/id_ed25519.pub 公钥,和~/.ssh/id_ed25519获取对私钥文件内容,获取到你的 public key

1
2
3
4
5
6
7
8
9
10
11
12
Linux@Linux-ThinkCentre-E75:~/文档/blogs$ cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK/QJbu+k40c8i7ZioAdLRVwgOeNsO+Ea7aad1LdG9z7 bs0716@126.com

Linux@Linux-ThinkCentre-E75:~/文档/blogs$ cat ~/.ssh/id_ed25519
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACCv0CW7vpONHPIu2YqAHS0VcIDnjbDvhGu2mndS3Rvc+wAAAJiJxTPFicUz
xQAAAAtzc2gtZWQyNTUxOQAAACCv0CW7vpONHPIu2YqAHS0VcIDnjbDvhGu2mndS3Rvc+w
AAAECrAEvFII+Wco2D/c3kSQaAymNCLIo5FvlbG3axBB3H7q/QJbu+k40c8i7ZioAdLRVw
gOeNsO+Ea7aad1LdG9z7AAAADmJzMDcxNkAxMjYuY29tAQIDBAUGBw==
-----END OPENSSH PRIVATE KEY-----
Linux@Linux-ThinkCentre-E75:~/文档/blogs$
  1. 首次确认,需要确认并添加主机到本机SSH可信列表
    要注意按照命令提示输入 yes
1
2
3
4
5
6
7
Linux@Linux-ThinkCentre-E75:~/文档/blogs$ ssh -T git@gitee.com
The authenticity of host 'gitee.com (212.64.63.190)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitee.com,212.64.63.190' (ECDSA) to the list of known hosts.
Hi 望月砂! You've successfully authenticated, but GITEE.COM does not provide shell access.
Linux@Linux-ThinkCentre-E75:~/文档/blogs$

(四)配置部署用户信息

按照官方文档确认身份标识。

1
2
3
```bash
Linux@Linux-ThinkCentre-E75:~/文档/blogs$ git config --global user.email "bs0716@126.com"
Linux@Linux-ThinkCentre-E75:~/文档/blogs$ git config --global user.name "Linuxdeepin007"

个人博客搭建002_电脑上迁移博客
https://linuxdeepin007.github.io/code.github.io/2022/11/01/个人博客搭建002_电脑上迁移博客/
作者
望月砂
发布于
2022年11月1日
更新于
2023年10月23日
许可协议