SSH免密登录配置
SSH免密登录配置
本地生成密钥文件: $ ssh-keygen 输出: Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): 直接enter Enter passphrase (empty for no passphrase): 继续直接按enter Enter same passphrase again: 继续直接按enter 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: 10:98:86:e7:78:c8:24:87:dc:3a:8a:30:ca:08:4e:8c root@min1 The key's randomart image is: +--[ RSA 2048]----+ |.... o. | |o.+.= . | |o=.* . | |E=+ o . | |@... S | |=o | | | | | | | +-----------------+ 出现上面情况表示key生成成功,放在了root/.ssh/id_rsa文件中,无密码。 |
将key文件拷贝到目标机 $ ssh-copy-id 192.168.71.10 输出: The authenticity of host '192.168.71.10 (192.168.71.10)' can't be established. RSA key fingerprint is fa:a9:1b:a8:d3:f8:4b:39:23:c6:4b:e6:21:c1:df:99. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.71.10' (RSA) to the list of known hosts. root@192.168.71.10's password: 输入目标机192.168.71.10密码 Now try logging into the machine, with "ssh '192.168.71.10'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting. 至此表示拷贝成功了,输出说可以尝试登陆了。 |
登陆测试 [root@min1 ~]$ ssh 192.168.71.10 Last login: Wed Nov 22 00:58:34 2017 from 192.168.71.1 [root@min2 ~]$ ^C 这样就可以远程运行脚本及操作各种指令了。 |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!