《小问题就和苍蝇一样!:~/.ssh》shit!!!!!!!!!!!!!!!!!!!!!!!!
1.配置阶段
(0)启动 sshd:systemctl start sshd
(1)暂时关闭防火墙
systemctl stop firewalld
(2)查看防火墙状态
systemclt status firewalld
(3)vim /etc/ssh/sshd_config
单击i开启插入
etc进入命令领域后
:wq退出
:q!强制不保存退出
2.Linux 通过密钥登录其他 Linux 系统
(1)登录服务器 以密钥用户登录的用户名密码方式登录到服务器,在服务器上制作密钥 对。 mylinux@ubuntu:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/mylinux/.ssh/id_rsa): 回车 Enter passphrase (empty for no passphrase): 回车或输入密码 Enter same passphrase again: 回车或输入密码 Your identification has been saved in /home/mylinux/.ssh/id_rsa.私钥 Your public key has been saved in /home/mylinux/.ssh/id_rsa.pub.公钥 The key fingerprint is: SHA256:e83NrG4Tu86mbQLWtH8M964dJkjV0+PHuA2yJFU8zUk mylinux@ubuntuThe key's randomart image is: +---[RSA 2048]----+ | .oE.| | .+.+| | .. =.| | ... .oo| | So.oo o.o| | o.+=+*.+.| | ....o+B=+.| | ..oB.=.o| | .OB+.oo| +----[SHA256]-----+ 用户的家目录中生成了一个 .ssh 的隐藏目录,内含两个密钥文件。id_rsa 为 私钥,id_rsa.pub 为公钥。
(2)服务器上安装公钥 mylinux@ubuntu:~$ cd .ssh mylinux@ubuntu:~/.ssh$ cat id_rsa.pub >>authorized_keys mylinux@ubuntu:~/.ssh$ chmod 600 authorized_keys
(3)将私钥下载到客户端 mylinux@ubuntu~/.ssh$scp id_rsa 客户端 ip 或主机名:~/.ssh
(4)客户端 ssh 登录 mylinux@ubuntu:~$ssh 服务端 ip 或主机名