Mac 配置与 Linux 通讯

Mac 配置与 Linux 通讯

1. 安装 sh-copy-id

sudo curl -L https://raw.githubusercontent.com/beautifulcode/ssh-copy-id-for-OSX/master/install.sh | sh

 

或者

brew install ssh-copy-id

 

2. 生成登录公钥私钥对

$ ssh-keygen -o -t rsa -C “[email protected]” -b 4096

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/zongxun/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /Users/zongxun/.ssh/id_rsa

Your public key has been saved in /Users/zongxun/.ssh/id_rsa.pub

The key fingerprint is:

SHA256:ewAVKPAGTO/lI+lE2VwUDThKV2xoSY8JINGqTGDleMY [email protected]

The key’s randomart image is:

+—[RSA 4096]—-+

|o=*+…OO=       |

|.o*+o=O*o .      |

|oo E*=Bo.        |

|..o+.+ .         |

|+   = o S        |

|.. o . . o       |

|    .   . .      |

|         .       |

|                 |

+—-[SHA256]—–+

➜  ~ cat /Users/zongxun/.ssh/id_rsa.pub

 

3. 拷贝公钥到远程主机

~ cat /Users/zongxun/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCtWnPklKrtkQ9tWm68M+YOLgJBOr4NFI8u4KVGEY+SZS2WjYOjc1A/4at8ccal2xyd0ajH8ytiXgW5q1ngCYgM3QBOoZ6Wenq6FEWwRR9o7Txwf+0d2Y1/goRfYEJ+S940ErrIyb5KCEJFOvnu5DwoJTULolel1+gxYWAyJdhnCCJbB9KHuMTwcVDRpkz4tGQHMgyq8JthpJcUTqeIG/jwmEioVapm9llcOJIFCmaGkO7HOSdH5CczMqT6WndXWx2TtOlUxXggPBqkKi3yqm21XPz1Ent5Lfgl0PNfamGHU6Znm3RViZl8Q8A3yoZlLS8o7ca4P8gT9VIcYwxPzs7sdQvr6wur65YTJFTpE95lUUGZNbCTj/2ZBvX54Yiosd5kQ9U/6zh66LLilagBOx7OtRHex9LIxrRuUWDqBewjvZSERY5/ZylOYQ6KX+xC1GgkOhF2giOqtQxS7Q4ORF9czIdvmSeI0TQKQIsxcIaebiwaI2FLzE+FNDdO8imHV9rPNN+wuu2T9/LkemquQAnhDlGXQzszB/Nvzv0BDjHv+TsbOvFVUdB6VRevlz+c6tSvhJXDY/fluAYnl6yBK12X34PFhUta8K+QVxq/TAOmE9ZJZosp96Pa3abHxW2I7BbVajon94V/dU66d+osbuTXuQ/rjIaWy55nZOzi9QVlkw== [email protected]

➜  ~ ssh-copy-id [email protected]

/opt/homebrew/opt/ssh-copy-id/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/Users/zongxun/.ssh/id_rsa.pub”

/opt/homebrew/opt/ssh-copy-id/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/opt/homebrew/opt/ssh-copy-id/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys

[email protected]‘s password:

 

Number of key(s) added:        1

 

Now try logging into the machine, with:   “ssh ‘[email protected]‘”

and check to make sure that only the key(s) you wanted were added.

 

4. 访问远程主机

➜  ~ ssh [email protected]

Activate the web console with: systemctl enable –now cockpit.socket

 

Last login: Thu Mar  2 14:56:56 2023 from 172.7.245.44

[root@kind2 ~]#

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/156323.html<

(0)
运维的头像运维
上一篇2025-03-15 20:51
下一篇 2025-03-15 20:52

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注