---
title: "Linux SSH服务开通[Fedora 12]"
author: "pigfans"
date: "2012-12-26T14:32:26Z"
tags: []
categories: ["操作系统"]
slug: "linux-ssh-fedora-12"
draft: false
lastmod: "2013-01-08T10:08:59Z"
id: 1754434
url: "https://pigfans.iteye.com/blog/1754434"
---

近期安装了一台Fedora 12虚拟机, 可以在自己电脑上ssh连接到这台Linux, 用起来很方便. 这里记一下是怎么配置的.

1\) 安装openssh-server

\[root@localhost ~]# yum install openssh-server  
2\) 查看是否已成功安装openssh-server

\[root@localhost ~]# rpm -qa | grep openssh-server

openssh-server-5.3p1-19.fc12.i686  
\[root@localhost ~]#

3\) 修改ssh服务的配置文件

配置ssh服务的运行参数, 是通过修改配置文件/etc/ssh/ssh\_config实现的. /etc/ssh/ssh\_config文件的配置选项非常多, 但大部分都已经用"#"注释掉了.

#Port 22 

#Protocol 2,1 

#PermitRootLogin yes 

配置完保存配置文件, 不过如果没什么特殊的要求这都不用配置.

 

1.启动SSH服务

# systemctl start sshd.service

 

2.随系统一起启动服务

# systemctl enable sshd.service

 

3.开启防火墙22端口

# iptables -I INPUT -p tcp --dport 22 -j ACCEPT

 

 

也可以将上述参数加入防火墙配置中：

   #vi /etc/sysconfig/iptables

  加入：-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

   保存后重启iptables即可

 

如果仍然有问题，就可能是SELinux导致的

关闭selinux：

修改/etc/selinux/config文件中的SELINUX="" 为 disabled，然后重启

===================================

```
[root@CC init.d]# systemctl start sshd.service

[root@CC init.d]# systemctl enable sshd.service
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service'


[root@CC init.d]# iptables -I INPUT -p tcp --dport 22 -j ACCEPT
 
===================================
```

 

重启后生效：

iptables-save &gt;/etc/sysconfig/iptables