ssh-keygen -t rsa -b 4096 -C "[email protected]"
...
Enter a file in which to save the key (/home/you/.ssh/algorithm): <key_name>
Enter passphrase (empty for no passphrase): [输入密码]
Enter same passphrase again: [再次输入密码]
cat ~/.ssh/<key_name>.pub
Title : 为新密钥添加描述性标签 Key : 粘贴COPY的公钥内容
cd ~/.ssh
# 设置访问权限
chmod 600 <key_name>
# 生成SSH配置文件
cat > config << EOF
Host github.com
Hostname ssh.github.com
Port 443
IdentityFile ~/.ssh/<key_name>
UpdateHostKeys yes
Compression yes
User git
EOF
ssh -T [email protected]
...
Are you sure you want to continue connecting (yes/no)? <yes>
...
Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.
如果找不到软件,直接下载安装 或 更换软件源 Linux 版本库管理
在 Alpine 上安装 Docker 真是一件让人感觉非常愉快的事情,因为过程非常简单。
$ nano /etc/apk/repositories
因为 docker 在社区的库里,所以要打开 community 的源。
#/media/cdrom/apks
http://mirrors.tuna.tsinghua.edu.cn/alpine/v3.16/main
http://mirrors.tuna.tsinghua.edu.cn/alpine/v3.16/community
#http://mirrors.tuna.tsinghua.edu.cn/alpine/edge/main
#http://mirrors.tuna.tsinghua.edu.cn/alpine/edge/community
#http://mirrors.tuna.tsinghua.edu.cn/alpine/edge/testing
$ apk update
$ apk add docker docker-cli-compose
# 这里要特别注意,docker compose 的包名在 Alpine 里是 docker-cli-compose,不是 docker-compose-plugin。
# docker-compose 包是 compose 的独立安装包,官方已经不再支持这种安装方式。
...
$ docker -v
Docker version 20.10.16, build aa7e414fdcb23a66e8fabbef0a560ef1769eace5
$ docker compose version
Docker Compose version v2.12.2
~# nano /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.10.16/24
gateway 192.168.10.10
hostname alpine
# nano /etc/resolv.conf
nameserver 114.114.114.114
~# service networking restart
特点:
不同版本:
Alpine 有许多版本,其中 VIRTUAL 是专门针对虚拟环境优化过的,所以主要使用这个版本来安装。
https://www.alpinelinux.org/downloads/
...
# 使用启动盘启动后,直接使用 root 登录系统
localhost login: root
...
localhost:~# setup-alpine
# 选择键盘布局
# 这里两个都选 cn 或都不选
...
Select keyboard layout: [none] cn
...
Select variant (or 'abort'): cn
# 设置主机名
...
Enter system hostname (fully qualified form, e.g. 'foo.example.org') [localhost] home
# 设置网络
...
Which one do you want to initialize? (or '?' or 'done') [eth0] eth0
Ip address for eth0? (or 'dhcp', 'none', '?') [dhcp] dhcp
Do you want to do any manual network configuration? (y/n) [n] n
# or 手动输入IP地址
Ip address for eth0? (or 'dhcp', 'none', '?') [dhcp] 192.168.10.16/24
Gateway? (or 'none') [none] 192.168.10.10
Do you want to do any manual network configuration? (y/n) [n] n
DNS domain name? (e.g 'bar.com')
DNS nameserver(s)? 114.114.114.114
# 设置密码
...
New password:
...
Retype password:
# 设置时区
# PRC 代理中国,也可以输入 Asia/,再输入 Shanghai
...
Which timezone are you in? ('?' for list) [UTC] PRC
# 设备代理
...
HTTP/FTP proxy URL? (e.g. 'http://proxy:8080', or 'none') [none] none
# 设置更新源
# f 是自动测试并选择最快的源,建议使用
...
Enter mirror number (1-74) or URL to add (or r/f/e/done) [1] f
#
Setup a user? (enter a lower-case loginname, or 'no') [no] no
# 设置ssh服务
Which ssh server? ('openssh', 'dropbear', or 'none') [openssh] openssh
# 这里一定要输入 yes
# 许多教程都说 Alpine 默认没有远程登录,都上手动修改,其实是可以在安装时就设备好的
Allow root ssh login? ('?' for help) [prohibit-password] yes
Enter ssh key or URL for root (or 'none') [none] none
# 设置磁盘
...
Which disk(s) would you like to use? (or '?' for help or 'none') [none] sda
...
How would you like to use it? ('sys', 'data', 'crypt', 'lvm' or '?' for help) [?] sys
...
WARNING: Erase the aboue disk(s) and continue? (y/n) [n] y
...
Installation is complete. Please reboot.
# 到这里安装全部完成
# 准备应答文件
home:~# reboot
home:~# rc-service iptables stop
home:~# rc-update del iptables
为家里的微形PVE服务器买了山克的UPS,发现与 linux 连接使用还是需要安装一下的,而且市场上基本都是 OEM 的产品,所以操作过程通用
# 查看代理
git config --global --get http.proxy
git config --global --get https.proxy
# 设置代理
git config --global http.proxy http://[username:passwrod@]ip or URL:port
git config --global https.proxy http://[username:passwrod@]ip or URL:port
# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
# 只代理github.com
git config --global --get http.https://github.com.proxy
git config --global --get https.https://github.com.proxy
git config --global http.https://github.com.proxy http://[username:passwrod@]ip or URL:port
git config --global https.https://github.com.proxy http://[username:passwrod@]ip or URL:port
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy
# push设置
git config --global push.default simple
git clone https://[email protected]/xxxx/xxxx.git
# or
git clone [email protected]:xxxxx/xxxxx.git
# 克隆指定分支,到指定目录
git clone -b branch-name repo path
git config user.name "Your Name"
git config user.email [email protected]
先在githubh上创建好项目
尝试使用 Ubuntu 的 Snap 后,发现真的非常方便。
看过Snap的介绍以后,发现Snap的沙盒理念非常先进,在存储基本不成问题背景下,会系统环境的影响更小。
而且docker-compose命令也会一起安装,更是方便。
$ sudo snap install docker
# 设置开机启动
$ sudo snap start docker --enable
# 确认服务状态
$ sudo snap services docker
# 查看服务详情
$ service snap.docker.dockerd status
使用sudo安装后要注意以后调用时,都要使用sudo命令前缀。
# 安装目录
/snap/docker/current
# 服务启动配置文件
/etc/systemd/system/snap.docker.dockerd.service
# 配套 AppArmor 配置文件
/var/lib/snapd/apparmor/profiles/snap.docker.docker
/var/lib/snapd/apparmor/profiles/snap.docker.dockerd
# 默认 Unix Socket 文件路径
unix:///var/snap/docker/current/run/docker/libcontainerd/docker-containerd.sock