windows 通过ssh连接linux

服务器redhat9.0 客户端:win7

1、下载相关工具,openssh 安装包5.0 地址 www.openssh.com 左侧linux  进入页面后 download

       下载putty windows下连接工具 ,puttygen 密匙转换工具

2、安装,下载的.tar.zip格式的安装包,./configure  make  make install  make clean            putty 无需安装

       启动  service sshd start

       设置开机启动  chkconfig   - - 345  sshd on      //345是runlevel

3、生成密匙,公匙  如果想使abc这个linux用户能够远程登陆的话,在linux服务器上输入如下命令

         # su abc

         % sshd-keygen  -t rsa    //注意,shhd-keygen  连在一起写

         linux会让你填写生成密匙的放置位置,默认为/home/abc/.ssh/    .ssh为隐藏文件夹,用ls -a 可见

         输入密匙口令

         这样就在/home/abc/.ssh 目录下 生成了 id_rsa 的密匙和 id_rsa.pub 的公匙

         % cat  id_rsa.pub >> authoried_keys

         %  rm -f id_rsa.pub

         % chmod  400 authoried_keys

4、配置.ssh 文件  /etc/ssh/sshd_config    /etc/hosts.deny    /etc/hosts.allow  

          /etc/ssh/sshd_config 文件中 修改如下:

windows 通过ssh连接linux_第1张图片

/etc/hosts.deny 中,增加  sshd : ALL

/etc/hosts.allow 中,增加 sshd :  10.10.139.0  只允许该网段的ip登陆,其他全部deny

5、将在linux下生成的密匙下载到要登陆到linux服务器的计算机上,双击puttygen,load 选择全部文件,选中linux中的密匙id_rsa,输入在linux中输入的密匙口令,保存密匙到windows下。关闭puttygen,打开putty,在左侧选择connection-ssh - auth  浏览 选中刚刚保存的ppk格式密匙,进入session输入linux ip地址,取一个名字linux-redhat,保存,以后双击该名字即可连接。


6、连接时出现,Network error : Connection timed out    : 原来是linux的防火墙阻止连接  关闭防火墙即可   /etc/init.d/iptables  stop  


参考网址:http://www.centospub.com/make/sshd.html

                 http://forums.sureshkumar.net/network-administration-hardware-troubleshooting/8783-putty-fatal-error-network-error-connection-timed-out.html




你可能感兴趣的:(linux)