(第一期)Mac item2 SSH连接服务器
iTerm2 是一款专为 macOS 设计的强大终端模拟器,它提供了许多优秀的功能:
- 支持分屏显示,可以在同一窗口打开多个终端会话
- 具有丰富的主题和配色方案,可以自定义终端外观
- 支持快捷键和命令自动补全,提高工作效率
- 集成了强大的搜索功能,方便查找历史命令和输出
- 可以保存和恢复工作会话,轻松管理多个终端窗口
- 支持 SSH 远程连接服务器,并可保存连接配置
软件获取:
- https://iterm2.com/
如何使用item2 连接服务器?¶
1.1 将主机列表保存在ssh-config-hosts文件中(文件名字自定义)¶
$ cat ~/.ssh/config
Include /Users/barry-boy/Desktop/lixie-work/note-k8s/ssh-config-hosts
User xxx
1.2 主机配置¶
cat ssh-config-hosts
Host m1.vm
HostName 192.168.0.201
1.3 尝试账号密码SSH¶
ssh user@m1.vm
1.4 使用密钥对SSH¶
ssh m1.vm
1.5 在线获取公钥¶
上传公钥
生成公钥和私钥
root@user:~# ssh-keygen //一路回车
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:J0s/ZHIRTj/UCcDQLHtxd5Qa0p3r2CYlcz7lPS7VaXU root@user
The key's randomart image is:
+---[RSA 3072]----+
| .=+.+o.o+|
| .o==.o++.|
| ooo+.o..|
| . .. = +E|
| S.= X.B|
| . X o @+|
| . o * o|
| . . . |
| . |
+----[SHA256]-----+
这个时候在.ssh目录下生成几个文件
$ ll ~/.ssh (shanghai/kube-prometheus)
total 392
-rw-r--r-- 1 barry-boy staff 171B 4 11 21:55 config
-rw------- 1 barry-boy staff 2.5K 11 13 2023 id_rsa
-rw------- 1 barry-boy staff 2.6K 4 26 2023 id_rsa.bak
-rw-r--r-- 1 barry-boy staff 571B 11 13 2023 id_rsa.pub # 上传公钥文件
-rw-r--r-- 1 barry-boy staff 589B 4 26 2023 id_rsa.pub.bak
-rw------- 1 barry-boy staff 87K 4 11 17:21 known_hosts
-rw------- 1 barry-boy staff 86K 4 11 17:21 known_hosts.old
测试公钥文件
curl https://openbayes.com/api/users/lixie/keys.txt