Browsing the archives for the ssh tag

linux下ssh使用rsa认证教程[原创]

in 服务器类

下面我们来对linux(centos)平台如何使用ssh的rsa认证功能来实现安全登录服务器的教程.为了安全我们一般不直接使用root这个用户,而使用其它用户来代替.如果需要root权限的时候,直接在服务器上进行su命令进行用户切换就可以了. 一.配置/etc/ssh/ssh_config文件 ServerKeyBits 1024 //# 注释取消,将768改为1024 PermitRootLogin no //# 注释取消,将yes改为no 禁止root登录 RSAAuthentication yes //# 启用 RSA 认证 PubkeyAuthentication yes //# 启用公钥认证 AuthorizedKeysFile //# .ssh/authorized_keys # 验证公钥的存放路径 PermitEmptyPasswords no //# 取消注释,禁止空密码登录 PasswordAuthentication no //# 取消注释,禁止使用密码方式登录,有密钥谁还用密码啊 注意一下,在centos5.0之前SSH服务需要指明版本,#Protocol 2,1 把前面的注释取消,选择自己需要的版本就行了。 重启sshd服务 service sshd restart 说明: 如果想做到最大化安全链接,可以考虑在配置有双网卡的服务器上设置只允许内网链接SSH,方法很简单, 首先在/etc/hosts.deny文件最后一行添加一句sshd: ALL 然后在/etc/hosts.allow的最后一行加上一句sshd: 192.168.0. 然后保存退出。 二.生成密匙 使用Linux主机生成的密匙,这里使用的是sysadmin这个用户,如果是使用其它用户的话,请在相应用户的home目录下面的.ssh文件夹里进行操作.这里我们创建一个sysadmin用户.

SSH 超时断开连接解决办法

in 服务器类

有2种方法 1、 配置服务器  #vi /etc/ssh/sshd_config 1)找到 ClientAliveInterval参数,如果没有就自己加一行 数值是秒,比如你设置为120 ,则是2分钟 ClientAliveInterval 120  2)ClientAliveCountMax 指如果发现客户端没有相应,则判断一次超时,这个参数设置允许超时的次数。如3 、5等自定义 修改两项参数后如下: ---------------------------- ClientAliveInterval 120 ClientAliveCountMax 0   ###在不允许超时次数 重新加载sshd服务。退出客户端,再次登陆即可验证。  2、 配置客户端 #vi  /etc/ssh/ssh_config 然后找到里面的 ServerAliveInterval 参数,如果没有你同样自己加一个就好了 参数意义相同,都是秒数,比如5分钟等  ServerAliveInterval 300 ===================================== 上面是配置需要服务器权限,如果没有服务器权限则可以使用这个方法,其思想是:客户端向服务器发一个消息,用于保持连接 secureCRT:在 "选项-> 终端-> 反空闲" 中设置每隔多少秒发送一个字符串,或者是NO-OP协议包. putty:putty -> Connection -> Seconds between keepalives ( 0 to turn off ), 默认为0, 改为300.

0 Comments

bad permissions:ignore key:/etc/ssh/ssh_host_dsa_key的解决办法

in 服务器类

Q: # cd /etc/rc2.d # ./S96sshd start @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0755 for '/usr/local/etc/ssh_host_key' are too open. It is recommended that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: /usr/local/etc/ssh_host_key Could not load host key: /usr/local/etc/ssh_host_key

0 Comments

CentOS配置SSH证书登录验证

in 服务器类

操作步骤: ————————– 1)先添加一个维护账号:msa 2)然后su – msa 3)ssh-keygen -t rsa 指定密钥路径和输入口令之后,即在/home/msa/.ssh/中生成公钥和私钥:id_rsa id_rsa.pub 4)cat id_rsa.pub >> authorized_keys 至于为什么要生成这个文件,因为sshd_config里面写的就是这个。 然后chmod 400 authorized_keys,稍微保护一下。 5)用psftp把把id_rsa拉回本地,然后把服务器上的id_rsa和id_rsa.pub干掉 6)配置/etc/ssh/sshd_config Protocol 22 ServerKeyBits 1024 PermitRootLogin no  #禁止root登录而已,与本文无关,加上安全些

2 Comments

ubuntu开启SSH服务

in 服务器类

网上有很多介绍在Ubuntu下开启SSH服务的文章,但大多数介绍的方法测试后都不太理想,均不能实现远程登录到Ubuntu上,最后分析原因是都没有真正开启ssh-server服务。最终成功的方法如下: sudo apt-get install openssh-server Ubuntu缺省安装了openssh-client,所以在这里就不安装了,如果你的系统没有安装的话,再用apt-get安装上即可。 然后确认sshserver是否启动了: ps -e |grep ssh 如果只有ssh-agent那ssh-server还没有启动,需要/etc/init.d/ssh start,如果看到sshd那说明ssh-server已经启动了。 ssh-server配置文件位于/ etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。然后重启SSH服务: sudo /etc/init.d/ssh resar ssh连接:ssh xjtu129@202.117.15.165

0 Comments

如何通过ssh修改ip

in 服务器类

Q:有些时候我们需要修改服务器的ip,但服务器又不在本地,只能ssh连接,这个时候怎么办哪? A:/etc/rc.d/netif restart && /etc/rc.d/routing restart 以下是freebsd下的相关命令: #关闭网卡 ifconfig network-interface down #启动网卡 ifconfig network-interface up #查看尚未启动的网卡 ifconfig -d #查看已启动网卡 #重启路由 /etc/rc.d/routing restart

0 Comments

Freebsd限定特定IP来使用ssh登录

in 服务器类

法1. #ee /etc/hosts.allow 在ALL : ALL : allow的前面加上 sshd : your IP : allow sshd : ALL : deny 就OK了。 法2. 修改/etc/ssh/sshd_config 加入 Allowusers admin@172.16.2.188 意思为 只允许admin从172.16.2.188登陆 法3. 防火墙

0 Comments

freebsd ssh 服务器登录失败问题的解决

in 服务器类

编辑/etc/ssh/sshd_config 保证设置以下参数: PermitRootLogin yes PasswordAuthentication yes UseDNS no LoginGraceTime 0

0 Comments

FreeBSD下SSH配置

in 服务器类

sshd的配置文件一般位于/etc/ssh/sshd_config。

  终端下:#ee /etc/ssh/sshd_config

  ---------------------------------------------

  #Protocol 2,1

  修改为:

  Protocol 2

  #ListenAddress 0.0.0.0

  修改为:

  ListenAddress 0.0.0.0

  #PermitRootLogin yes

  修改为

  PermitRootLogin yes

  (Linux上默认允许root用户登录,此处可不修改。)

0 Comments

FreeBSD下如何开启SSH

in 服务器类

首先vi编辑/etc/inetd.conf,去掉ssh前的#,保存退出
编辑/etc/rc.conf
最后加入:sshd_enable="yes"即可
激活sshd服务:
techo#/etc/rc.d/sshd start
用下面命令检查服务是否启动,在22端口应该有监听。
#netstat -an ## check port number 22
最后
vi /etc/ssh/sshd_config

0 Comments