ssh fedora_如何在Fedora Linux上启用SSH服务?

ssh fedora

How to enable SSH service on Fedora Linux? By default, it seems ssh is not enabled.

如何在Fedora Linux上启用SSH服务? 默认情况下,似乎未启用ssh。

Fedora may not have sshd service installed/enabled by default. You will need to install and configure it by yourself. The following instructions is for Fedora 22 as an example.

Fedora可能默认没有安装/启用sshd服务。 您将需要自己安装和配置它。 以下说明以Fedora 22为例。

First, install the sshd server by

首先,通过以下方式安装sshd服务器

# dnf install openssh-server

Then, start the sshd service and make it automatically start next time you boot by

然后,启动sshd服务,并使其在下次启动时自动启动

# systemctl start sshd.service
# systemctl enable sshd.service

Last, enable external connection to the port 22 (the default one) by configuring the firewall you are using.

最后,通过配置您使用的防火墙,启用到端口22的外部连接(默认端口)。

Note: you may not need additional configurations if 22 is already opened.

注意:如果已经打开22,则可能不需要其他配置。

If you are using firwalld, you may use the firewall-config tool (install it by dnf install firwall-config if you haven’t it).

如果您使用的是firwalld,则可以使用firewall-config工具(如果没有,请通过dnf install firwall-config )。

Some further readings that you may find useful:

一些进一步的阅读可能对您有用:

How to enable iptables on Fedora 20 https://www.systutorials.com/241222/how-to-enable-iptables-on-centos-7-fedora-20/

如何在Fedora 20上启用iptables https://www.systutorials.com/241222/how-to-enable-iptables-on-centos-7-fedora-20/

Basic iptables configuration for Linux https://www.systutorials.com/241412/basic-iptables-configuration-for-linux/

Linux的基本iptables配置 https://www.systutorials.com/241412/basic-iptables-configuration-for-linux/

How to use iptables to limit rates new SSH incoming connections from each IP on Linux https://www.systutorials.com/241409/how-to-use-iptables-to-limit-rates-new-ssh-incoming-connections-from-each-ip-on-linux/

如何使用iptables限制Linux上每个IP的新SSH传入连接的速率https://www.systutorials.com/241409/how-to-use-iptables-to-limit-rates-new-ssh-incoming-connections-从Linux上的每个IP /

How to log connections hitting certain rules in iptables on Linux https://www.systutorials.com/241413/how-to-log-connections-hitting-certain-rules-in-iptables-on-linux/

如何在Linux上的iptables中记录达到某些规则的连接记录https://www.systutorials.com/241413/how-to-log-connections-hitting-certain-rules-in-iptables-on-linux/

Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。


A simple destop firewall:

一个简单的停止防火墙:

http://www.cyberciti.biz/faq/linux-detect-port-scan-attacks/

http://www.cyberciti.biz/faq/linux-detect-port-scan-attacks/

copy paste from #! until the end (including exit 0) and put it in a file ending on sh (bash script).Make it executable.Don’t forget to check the name of your network interface with ifconfig.

从#复制粘贴! 直到结束(包括出口0),然后将其放入以sh(bash脚本)结尾的文件中。使它可执行。不要忘记使用ifconfig检查网络接口的名称。

#!/bin/bash
IPT="/sbin/iptables"
 
echo "Starting IPv4 Wall..."
$IPT -F
$IPT -X
$IPT -t nat -F
$IPT -t nat -X
$IPT -t mangle -F
$IPT -t mangle -X
modprobe ip_conntrack
 
BADIPS=$(egrep -v -E "^#|^$" /root/scripts/blocked.fw)
PUB_IF="eth0"
 
#unlimited 
$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT
 
# DROP all incomming traffic
$IPT -P INPUT DROP
$IPT -P OUTPUT DROP
$IPT -P FORWARD DROP
 
# block all bad ips
for ip in $BADIPS
do
    $IPT -A INPUT -s $ip -j DROP
    $IPT -A OUTPUT -d $ip -j DROP
done
 
# sync
$IPT -A INPUT -i ${PUB_IF} -p tcp ! --syn -m state --state NEW  -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Drop Syn"
 
 
$IPT -A INPUT -i ${PUB_IF} -p tcp ! --syn -m state --state NEW -j DROP
 
# Fragments
$IPT -A INPUT -i ${PUB_IF} -f  -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Fragments Packets"
$IPT -A INPUT -i ${PUB_IF} -f -j DROP
 
 
# block bad stuff
$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL ALL -j DROP
 
$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL NONE -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "NULL Packets"
$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL NONE -j DROP # NULL packets
 
$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
 
$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags SYN,FIN SYN,FIN -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "XMAS Packets"
$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP #XMAS
 
$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags FIN,ACK FIN -m limit --limit 5/m --limit-burst 7 -j LOG --log-level 4 --log-prefix "Fin Packets Scan"
$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags FIN,ACK FIN -j DROP # FIN packet scans
 
$IPT  -A INPUT -i ${PUB_IF} -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
 
 
# Allow full outgoing connection but no incomming stuff
$IPT -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -o eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
 
# allow ssh only
$IPT -A INPUT -p tcp --destination-port 22 -j ACCEPT
$IPT -A OUTPUT -p tcp --sport 22 -j ACCEPT
 
# allow incoming ICMP ping pong stuff
$IPT -A INPUT -p icmp --icmp-type 8 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -p icmp --icmp-type 0 -m state --state ESTABLISHED,RELATED -j ACCEPT
 
# No smb/windows sharing packets - too much logging
$IPT -A INPUT -p tcp -i eth0 --dport 137:139 -j REJECT
$IPT -A INPUT -p udp -i eth0 --dport 137:139 -j REJECT
 
# Log everything else
# *** Required for psad ****
$IPT -A INPUT -j LOG
$IPT -A FORWARD -j LOG
$IPT -A INPUT -j DROP
 
# Start ipv6 firewall
# echo "Starting IPv6 Wall..."
#/root/scripts/start6.fw
 
exit 0

翻译自: https://www.systutorials.com/how-to-enable-ssh-service-on-fedora-linux/

ssh fedora

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值