[wolf@wulaoer.org 🔥🔥🔥🔥 sh]# 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:vqnsRUf63m6coKRjOmXYYk55RiREXe2y104t+XmzF+Y root@Swarm The key's randomart image is: +---[RSA 3072]----+ | oo. ... | | . o . | | o .. | | . .o. | | = So.. o | | * *oooo = .o | | + * ooo.= +o..| | o.+..+ .= oEo| | .=+oo .oo o+| +----[SHA256]-----+ [wolf@wulaoer.org 🔥🔥🔥🔥 sh]# ssh-copy-id root@10.211.55.25 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@10.211.55.25's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@10.211.55.25'" and check to make sure that only the key(s) you wanted were added.
免密码登录完成了,下面我在本地创建一个脚本,就创建文件的脚本吧,方便后期,针对服务的管理。
[wolf@wulaoer.org 🔥🔥🔥🔥 sh]# vim tach.sh #!/bin/bash mkdir -p /apps/works/{service,logs,data} ls /apps/works/ [wolf@wulaoer.org 🔥🔥🔥🔥 sh]# ssh root@10.211.55.25 < tach.sh Pseudo-terminal will not be allocated because stdin is not a terminal. data logs service [wolf@wulaoer.org 🔥🔥🔥🔥 sh]# ssh root@10.211.55.25 "date" Fri Apr 28 14:20:37 CST 2023
这样就完成脚本的创建,并查看文件,我们可以登录到25机器上看一下,一定是创建成功了,如果有多个机器都需要执行的话,我们可以把ip地址写到一个文件中,然后打开文件,循环ip地址就可以了。这里就不测试了,好了,没有了看些其他的吧。
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏