作者:chen人气:0来源:网吧系统下载站2014-05-16 10:53:54
网上该类教程很多,但还是记录下,方便以后查询的时候使用。
两台服务器,内网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 ~]#
继续阅读:ssh
2017-05-03Putty(开源Telnet/SSH客户端) v1.0 简体中文版
2017-01-13Windows下SSH爆破小工具
2016-12-14processhacker绿色的进程磁盘读写
2016-10-22Sshun锁屏 v4.6.0 绿色版
2016-09-05SSH登录很慢的解决办法
2016-08-25流控大师,SSH改网卡口教程
2016-01-21XShell(免费SSH客户端)v5.0.0835中文版
2015-12-22Xshell(ssh客户端工具) v5.0.0835 绿色特别版
2015-12-08流控忘记密码(web修改 SSH修改 单机接键盘修改)
2015-10-22小米路由器开启SSH图文教程