linux中ssh免密通信的实现

发布时间:2024-03-17
服务器
什么是ssh
管理员可以通过远程登陆的方式,对通过网相连的分散于各处的多台主机进行管理操作。
管理员可以对远程主机进行如下操作:
远程登陆
远程命令执行
远程文件传输
遗憾的事情是:这些操作不安全!
使用纯文本口令,并用明文发送
信息可能会被截取,口令可能会被检索
未经授权的人员使用截取的口令登陆系统而对系统造成危害
在日常操作练习时,用ssh登录其他主机时,可能会每次都需要输入登录密码,哪怕用scp复制东西也需要。
为了更方便快捷的切换主机,ssh免密通信不失为更好的选择;
用ssh-keygen生成密钥,默认保存在本地的/root/.ssh/id_rsa
然后在用ssh-copy-id分发至目标主机之上;登录用户@主机名或ip地址
注意:
1.最好是用主机名,在/etc/hosts文件中写入主机名和对应的ip地址;
2.免密通信需要双方相互认证,所以也需要在目标主机对本机做一次相同的操作;
[root@www ~]# ssh-keygen -t rsa -p \\\'\\\' generating public/private rsa key pair.enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa already exists.overwrite (y/n)?[root@www ~]#ssh-copy-id -i .ssh/id_rsa.pub root@172.16.75.1/usr/bin/ssh-copy-id: info: source of key(s) to be installed: .ssh/id_rsa.pubthe authenticity of host \\\'172.16.75.1 (172.16.75.1)\\\' can\\\'t be established.ecdsa key fingerprint is sha256:yxhbts9mfk2iqc4gtow4rl8vohvfqc1caamjxuf3wec.ecdsa key fingerprint is md5:2c:c0:94:e8:3a:e4:74:88:c0:d8:e0:01:20:81:1d:8e.are you sure you want to continue connecting (yes/no)? 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 keysroot@172.16.75.1\\\'s number of key(s) added: 1now try logging into the machine, with: ssh \\\'root@172.16.75.1\\\'and check to make sure that only the key(s) you wanted were added.以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持西部数码。
上一个:MPL压力开关MPL压力传感器MPL传感器
下一个:dx版本过低(win10安装dx11显示的还是dx12)

蒸煮类营业执照能做什么
iphone怎么改字体风格(iphone手机如何改字体样式)
百合的夏季管理
虾衣花繁殖技术
建筑工程加固设计常识
电导率仪常见问题排除方法
电脑博览会(chinajoy英特尔展区)
特迪亚tediya称重传感器614-50Kg
电热毯亮灯但不发热什么原因(电热毯亮灯但不发热怎么办)
行政强制措施能否委托