ssh无密码登陆服务器
2014-05-08 14:29
323 查看
网上该类教程很多,但还是记录下,方便以后查询的时候使用。
两台服务器,内网ip分别是:
172.16.3.91 (本地机)
172.16.3.92 (远程机)
现在想在本地机上通过ssh 172.16.3.92登陆到远程机而不需要密码。
1.在本地机上用ssh-keygen 创建公钥私钥。
[root@rs-1 ~]# ssh-keygen -t rsa
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:
dc:fc:ea:b8:bb:74:d7:75:4b:6a:27:82:28:27:be:d6 root@rs-1
这个过程会提示输入密码,记住直接按回车就行,不要输入密码!要是输入了密码,一会访问的时候就需要输入密码了。
创建之后能看到如下两个文件
[root@rs-1 .ssh]# ll
total 24
-rw------- 1 root root 1675 May 8 07:18 id_rsa
-rw-r--r-- 1 root root 391 May 8 07:18 id_rsa.pub
id_rsa是私钥
id_rsa.pub是公钥, 主要给远程机使用的
2.把公钥传到远程机上去。
[root@rs-1 .ssh]# scp id_rsa.pub root@172.16.3.92:~/.ssh/authorized_keys
Address 172.16.3.92 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
root@172.16.3.92's password:
id_rsa.pub 100% 391 0.4KB/s 00:00
3.ssh链接时候就不需要密码了,直接登陆到远程机
[root@rs-1 .ssh]# ssh 172.16.3.92
Address 172.16.3.92 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
Last login: Thu May 8 07:19:28 2014 from 172.16.3.91
[root@rs-2 ~]#
参考:/article/1655815.html
两台服务器,内网ip分别是:
172.16.3.91 (本地机)
172.16.3.92 (远程机)
现在想在本地机上通过ssh 172.16.3.92登陆到远程机而不需要密码。
1.在本地机上用ssh-keygen 创建公钥私钥。
[root@rs-1 ~]# ssh-keygen -t rsa
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:
dc:fc:ea:b8:bb:74:d7:75:4b:6a:27:82:28:27:be:d6 root@rs-1
这个过程会提示输入密码,记住直接按回车就行,不要输入密码!要是输入了密码,一会访问的时候就需要输入密码了。
创建之后能看到如下两个文件
[root@rs-1 .ssh]# ll
total 24
-rw------- 1 root root 1675 May 8 07:18 id_rsa
-rw-r--r-- 1 root root 391 May 8 07:18 id_rsa.pub
id_rsa是私钥
id_rsa.pub是公钥, 主要给远程机使用的
2.把公钥传到远程机上去。
[root@rs-1 .ssh]# scp id_rsa.pub root@172.16.3.92:~/.ssh/authorized_keys
Address 172.16.3.92 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
root@172.16.3.92's password:
id_rsa.pub 100% 391 0.4KB/s 00:00
3.ssh链接时候就不需要密码了,直接登陆到远程机
[root@rs-1 .ssh]# ssh 172.16.3.92
Address 172.16.3.92 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
Last login: Thu May 8 07:19:28 2014 from 172.16.3.91
[root@rs-2 ~]#
参考:/article/1655815.html
相关文章推荐
- Mac os x下配置 Android ndk 开发环境及案列讲解
- iOS 多参数 ...NS_REQUIRES_NIL_TERMINATION 的写法
- 时间可预测性的BSS
- Linux系统下启动MySQL的命令及相关知识
- Linux各类压宿包的解压方法
- 性能调优攻略
- C++中的默认函数与default和delete用法
- Java静态变量&实例变量&静态方法
- json化表单数据
- 如何让搜索引擎收录文章
- <div class="clear"></div>
- NTC测温中 经典温度查表算法--二分查找法
- llinux 执行级别
- 13年很多客户推广淘宝淘宝客站推广技巧视频教程COM “TARGET = ” _bla
- MyEclipse10修改User default location
- Nagios Ganglia网络监控
- 引用NPOI动态创建EXCEL表
- OpenSSL
- 火狐浏览器下new Date返回NaN的问题处理,以及日期yyyy-MM-dd格式化功能
- 黑客马拉松