Mac 电脑生成.ssh公钥

  • 进入.ssh目录中
$ cd ~/.ssh
  • 创建公钥和私钥
$ ssh-keygen -t rsa



------------------(如果非git配置,请忽略)-------------------------
⚠️⚠️⚠️⚠️
- 如果在git中需要配置邮箱的话使用如下命令
$ ssh-keygen -t rsa -C "[email protected]"


⚠️⚠️⚠️⚠️
- 查看邮箱配置(git config --list)
user.name=lizhiqiang17
[email protected]
  • 输入密钥的文件名,使用默认名回车即可
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:
78:13:76:05:4e:76:f6:b9:55:e4:4b:85:bc:fe:48:e0 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|          +.+. o+|
|         + + .ooo|
|        o o   ooo|
|       o o  . oo.|
|      . S  . o.. |
|       . .  E o  |
|             . o |
|              . .|
|                 |
+-----------------+

扩展

- 命令登陆服务器
ssh '用户名'@'ip'  -p '端口'  -i '私匙路径'
例:ssh [email protected]  -p 10022  -i /Users/lizhiqiang/.ssh/id_rsa


- 查看当前路径
pwd


- 拷贝当前文件到指定路径
sudo cp -r '当前路径文件名' '指定路径'
例:sudo cp -r test /export/home/wjkjapp


- 删除文件
sudo rm -rf '路径'
例:sudo rm -rf /export/home/wjkjapp/test

查看已有SSH

截屏2022-01-19 下午9.44.34.png

你可能感兴趣的:(Mac 电脑生成.ssh公钥)