centos 下启用sshd服务

centos 下启用sshd服务
ssh localhost
错误信息为:ssh: connect to host localhost port 22: Connection refused
这种错误很主要的一个原因是sshd服务没有启动,先启动sshd服务后就没有问题了

1、查卡服务是否启用
ps -ef | grep ssh

2、如果没有启用 则要安装
yum install openssh-server

3、安装完之后开启
/etc/init.d/sshd start
如果/etc/init.d/sshd start出现:
Generating SSH1 RSA host key: [FAILED]
解决办法:
$ yum search openssh
$ sudo yum install openssh
如果已经安装openssh,启动sshd
$ sudo /etc/init.d/sshd start
sshd re-exec requires execution with an absolute path
[honki@localhost ~]$ sudo service sshd start
Generating SSH1 RSA host key: [ OK ]
Generating SSH2 RSA host key: [ OK ]
Generating SSH2 DSA host key: [ OK ]
Starting sshd: [ OK ]

4、如果还是连不上 关闭防火墙
/etc/init.d/iptables stop

如此即可。


[b]ssh localhost 免登录:[/b]

[bigdata@localhost ~]$ mkdir .ssh
[bigdata@localhost ~]$ chmod 700 .ssh
[bigdata@localhost ~]$ cd .ssh/
[bigdata@localhost .ssh]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
一路回车
Enter file in which to save the key (/home/bigdata/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/bigdata/.ssh/id_rsa.
Your public key has been saved in /home/bigdata/.ssh/id_rsa.pub.
The key fingerprint is:
51:c6:8b:54:45:09:cf:47:c0:89:0a:80:44:73:2e:df bigdata@localhost.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
| o+.o. o=*++. |
| .+ . .ooo+. |
| . . o.o .o . |
| o . o.. . |
| . E S |
| |
| |
| |
| |
+-----------------+
[bigdata@localhost .ssh]$ ls -l
total 8
-rw-------. 1 bigdata bigdata 1675 Jan 24 15:54 id_rsa
-rw-r--r--. 1 bigdata bigdata 411 Jan 24 15:54 id_rsa.pub
[bigdata@localhost .ssh]$ cp id_rsa.pub authorized_keys
[bigdata@localhost .ssh]$ chmod 644 authorized_keys
[bigdata@localhost ~]$ ssh localhost
Last login: Thu Jan 24 15:55:14 2013 from localhost.localdomain

$vi /etc/ssh/sshd_config
RSAAuthentication yes # 启用 RSA 认证
PubkeyAuthentication yes # 启用公钥私钥配对认证方式
AuthorizedKeysFile .ssh/authorized_keys # 公钥文件路径(和上面生成的文件同)

service sshd restart
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值