码迷,mamicode.com
首页 > 系统相关 > 详细

Linux SSH无交互式访问配置

时间:2016-08-29 13:13:39      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:linux   ssh   无密码   

环境准备两台Linux服务器:

  1. 准备一台SSH服务端(系统环境centos6.5,ip地址192.168.100.100)

  2. 准备一台SSH客户端(系统环境centos6.5,ip地址192.168.100.101)

1.检查是否安装SSH软件包

[root@nfsserver ~]# rpm -qa openssh-server openssl
openssh-server-5.3p1-94.el6.x86_64
openssl-1.0.1e-15.el6.x86_64

2.启动SSH服务

[root@nfsserver ~]# /etc/init.d/sshd start

3.创建密钥对

[root@nfsserver ~]# ssh-keygen    一路回车

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:
94:89:72:48:48:bb:89:cc:00:af:c0:69:e4:e8:13:5f root@nfsserver
The key‘s randomart image is:
+--[ RSA 2048]----+
|.o...            |
|*.oo . . o       |
|+*o oEo +        |
|Booo.o .         |
|o=o.    S        |
|  .              |
|                 |
|                 |
|                 |
+-----------------+

4.拷贝公钥至客户端

[root@Server ~]# ssh-copy-id -i .ssh/id_dsa.pub root@192.168.100.101

The authenticity of host ‘192.168.100.101 (192.168.100.101)‘ can‘t be established.

RSA key fingerprint is 5d:1b:b2:67:84:23:83:f9:59:3b:bd:91:b5:8f:c2:a9.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘192.168.100.101‘ (RSA) to the list of known hosts.

root@192.168.100.101‘s password:

Now try logging into the machine, with "ssh ‘root@192.168.100.101‘", and check in:


  .ssh/authorized_keys


to make sure we haven‘t added extra keys that you weren‘t expecting.


5.测试登录,无需密码直接登录客户端

[root@Server ~]# ssh root@192.168.100.101


6.ssh-copy-id非22端口的使用方法

[root@Server ~]# ssh-copy-id -i  /root/.ssh/id_rsa.pub  ‘-p 端口号 root@192.168.100.101‘


Linux SSH无交互式访问配置

标签:linux   ssh   无密码   

原文地址:http://yinqiang1119.blog.51cto.com/10869441/1843799

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!