openssh免密登录
1.openssh免密登录配置
创建.ssh目录 权限改为700
[root@chenlinsen1 ~]# mkdir .ssh
[root@chenlinsen1 ~]# chmod 700 .ssh
ssh-keygen -t rsa 生成ssh的密钥
[root@chenlinsen1 ~]# ssh-keygen -t rsa
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:VKMQnAhOV3OUENOiaqQSpPcWoL+3XVWsAMMccmaawLM root@chenlinsen1
The key's randomart image is:
+---[RSA 3072]----+
| .+.o*/Oo.o |
| ++o.B*Boo o |
|o..+o. .+ o |
|+ E o . . o |
| * o . S o |
|o + o . |
|.. o . |
| . .. . |
| .... |
+----[SHA256]-----+
[root@chenlinsen1 ~]#
[root@chenlinsen1 ~]# ll .ssh/
total 8
-rw------- 1 root root 2602 Dec 22 17:10 id_rsa
-rw-r--r-- 1 root root 570 Dec 22 17:10 id_rsa.pub
[root@chenlinsen1 ~]#
ssh-copy-id 将密钥复制到另一个系统
[root@chenlinsen1 ~]# ssh-copy-id root@192.168.157.129
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.157.129 (192.168.157.129)' can't be established.
ECDSA key fingerprint is SHA256:GvevoHY71/dneUu6+Gk42MjtxAVkT29ffJCQeanrUbI.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/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@192.168.157.129's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.157.129'"
and check to make sure that only the key(s) you wanted were added.
[root@chenlinsen1 ~]#
cat .ssh/id_rsa.pub 查看文件
[root@chenlinsen1 ~]# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCTQNaZEq4ARScTv50Yg39g2E7cyTXioTFFTcid88BkFCH0+ukjndupnZc5zfw5viBybK8nhANVNeO1P6c656TjDtO17F+X4SdPX2WjMu/iR93b7iHYTQkoVAk6cZDDok/0ReQCKn+N7Zm6NHrN6IjC3YO/xCZ38oOAYumJZpL+HCEFAdbVx/eklRJ6t6L6wYwwQdjqxZtr1bvzJW4ql/FtOtfBch2ThL9NjRA3B0AlqMnP+rfpLJZH2l8Vldr38IcjpgRVHVLpGeuj/sFRlCew3A4CKga/ie3lxkRZ7+Y8dnU9T93CvSif1KvZIaRAh039XtYgW7BrDoaDqj2GcGwbjJ/m5+yIIXCbkOrbaNpw8M05MDqvgs3j3QKYM4b1jGTS7OAzkVB4OLDrISYBGG6idf+MiJawtHWAngkPKX6JJpERa1M1jcK9xz586XKrSTabX45GDFL9Sfj17jI0kzn7Kro1e45km4hZEvsuXYp1s2Afoyv/qzlCoPSKr4EuaF0= root@chenlinsen1
[root@chenlinsen1 ~]#
cat .ssh/authorized_keys 查看文件
[root@chenlinsen2 ~]# cat .ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCTQNaZEq4ARScTv50Yg39g2E7cyTXioTFFTcid88BkFCH0+ukjndupnZc5zfw5viBybK8nhANVNeO1P6c656TjDtO17F+X4SdPX2WjMu/iR93b7iHYTQkoVAk6cZDDok/0ReQCKn+N7Zm6NHrN6IjC3YO/xCZ38oOAYumJZpL+HCEFAdbVx/eklRJ6t6L6wYwwQdjqxZtr1bvzJW4ql/FtOtfBch2ThL9NjRA3B0AlqMnP+rfpLJZH2l8Vldr38IcjpgRVHVLpGeuj/sFRlCew3A4CKga/ie3lxkRZ7+Y8dnU9T93CvSif1KvZIaRAh039XtYgW7BrDoaDqj2GcGwbjJ/m5+yIIXCbkOrbaNpw8M05MDqvgs3j3QKYM4b1jGTS7OAzkVB4OLDrISYBGG6idf+MiJawtHWAngkPKX6JJpERa1M1jcK9xz586XKrSTabX45GDFL9Sfj17jI0kzn7Kro1e45km4hZEvsuXYp1s2Afoyv/qzlCoPSKr4EuaF0= root@chenlinsen1
[root@chenlinsen2 ~]#
ssh 远程登录
[root@chenlinsen1 ~]# ssh root@192.168.157.129
Last login: Thu Dec 22 16:47:23 2022 from 192.168.157.1
[root@chenlinsen2 ~]#
nfs配置
设置一个服务端
[root@chenlinsen2 ~]# hostname nfsserver
[root@chenlinsen2 ~]# bash
[root@nfsserver ~]#
[root@nfsserver ~]# yum -y install nfs-utils
Last metadata expiration check: 0:25:02 ago on Thu 22 Dec 2022 05:16:20 PM CST.
Dependencies resolved.
==================================================================