博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ssky-keygen + ssh-copy-id 无密码登陆远程LINUX主机
阅读量:4310 次
发布时间:2019-06-06

本文共 1618 字,大约阅读时间需要 5 分钟。

使用下例中ssky-keygen和ssh-copy-id,仅需通过3个步骤的简单设置而无需输入密码就能登录远程Linux主机。 

ssh-keygen 创建公钥和密钥。 
ssh-copy-id 把本地主机的公钥复制到远程主机的authorized_keys文件上。
ssh-copy-id 也会给远程主机的用户主目录(home)和~/.ssh, 和~/.ssh/authorized_keys设置合适的权限 。

步骤1: 用 ssh-key-gen 在本地主机上创建公钥和密钥

root@zc-Lenovo-B450:~$  ssh-keygenGenerating public/private rsa key pair.Enter file in which to save the key (/home/zc/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/zc/.ssh/id_rsa.Your public key has been saved in /home/zc/.ssh/id_rsa.pub.The key fingerprint is:db:fd:13:dc:f5:99:4b:0a:c1:53:bf:f3:5f:c3:5c:2e zc@zc-Lenovo-B450The key's randomart image is:+--[ RSA 2048]----+|                 ||             .   ||          . . .  ||           +   ..||        S   o. .B||         o o  =B+||        . . o E=*||             o.o+||              ..o|+-----------------+

步骤2: 用 ssh-copy-id 把公钥复制到远程主机上

root@zc-Lenovo-B450:~$ ssh-copy-id 192.168.0.191root@192.168.0.191's password: Now try logging into the machine, with "ssh '192.168.0.191'", and check in:  ~/.ssh/authorized_keysto make sure we haven't added extra keys that you weren't expecting.

步骤3: 直接登录远程主机

root@zc-Lenovo-B450:/home/zc# ssh 192.168.0.191Welcome to Ubuntu 11.10 (GNU/Linux 3.0.0-17-generic-pae i686) * Documentation:  https://help.ubuntu.com/364 packages can be updated.299 updates are security updates.New release '12.04 LTS' available.Run 'do-release-upgrade' to upgrade to it.You have new mail.Last login: Mon Feb  4 15:02:51 2013 from zc-lenovo-b450.local

 

转载于:https://www.cnblogs.com/firesnow/archive/2013/02/04/2891825.html

你可能感兴趣的文章
sql server从一个数据库复制一个表到另一个数据库的方法
查看>>
微软正式公布Win8版本 ARM版命名为Windows RT
查看>>
4.java设计模式-原型模式(prototype)
查看>>
Javaee -----01----javaee的环境搭建和html标签 ...
查看>>
JVM内存分布和垃圾回收
查看>>
DOM操作指令
查看>>
PHPCMS快速建站系列之类别调用及类别显示页面
查看>>
《第二章 感知机》
查看>>
HomeWork1_Login in
查看>>
javascript中的类
查看>>
新词发现博文收集
查看>>
input text focus去掉默认光影
查看>>
使用JsonP进行跨域请求
查看>>
HDU 5317 RGCDQ (数论素筛)
查看>>
学习JSP(一)
查看>>
node安装-Win+Linux+Mac osx
查看>>
cookie和session笔记
查看>>
Java中使用注释
查看>>
构建你的第一个App
查看>>
Network Mapper 嗅探工具
查看>>