OpenSSH پروتکل سرویس SSH است. OpenSSH برای ورود از راه دور، بک آپ گیری، انتقال فایل از راه دور به وسیله ی scp یا sftp و موارد بسیار دیگر پیشنهاد می شود. SSH بهترین راه برای نگهداری محرمانه و کامل اطلاعات و داده های تبادل شده بین دو شبکه و سیستم می باشد. هرچند، اصلی ترین مزیت آن تایید سرور، از طریق استفاده از رمزگذاری کلید عمومی است. این مطلب به شما نشان خواهد داد که چگونه سرور OpenSSH فعال بر لینوکس یا یونیکس را مانند سیستم برای بهبود امنیت SSHD محافظت کرد. پیشفرض های OpenSSH پورت TCP-22 سرور OpenSSH دارای یک فایل کانفیگ می باشد-sshd ( در /etc/ssh/ قرار گرفته شده) کانفیگ کردن فایل کلاینت OpenSSH- ssh (در /etc/ssh/ قرار گرفته شده) ۱.از کلید عمومی SSH برای لاگین استفاده کنید سرور OpenSSH هویت های مختلف و متنوعی را پشتیبانی می کند. به همین دلیل پیشنهاد می شود تا از کلید عمومی احراز هویت استفاده کنید. ابتدا، جفت کلید را بر اساس ssh-keygen پیشنهاد شده بر لپتاپ یا دسکتاپ محلی خودتان بسازید: نکته: DSA و RSA 1024 بایت یا کلید SSH پایین تر، ضعیف به شمار می روند. برای استفاده از آنها لطفا خودداری نمایید. کلید های RSA نسبت به کلید های ECDSA هنگامی که همگام سازی با کلاینت های SSH مد نظر است، ترجیح داده می شود. تمامی کلیدهای SSH یا ED25519 یا RSA می باشند. از نمونه های دیگر استفاده نکنید.
ssh-keygen -t key_type -b bits -C "comment"
ssh-keygen -t ed25519 -C "Login to production cluster at xyz corp"
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa_aws_$(date +%Y-%m-%d) -C "AWS key for abc corp clients"
ssh-copy-id -i /path/to/public-key-file user@host
ssh-copy-id user@remote-server-ip-or-dns-name
ssh-copy-id toshan@rhel7-aws-server
ssh toshan@rhel7-aws-server
sudo adduser toshan
id toshan
sudo usermod -aG wheel toshan
id toshan
sudo -i
sudo /etc/init.d/sshd status
sudo systemctl status httpd
PermitRootLogin no
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no
AuthenticationMethods publickey
PubkeyAuthentication yes
PubkeyAuthentication yes
AllowUsers toshan sepanta
DenyUsers root webii
PermitEmptyPasswords no
genpasswd() {
local l=$1
[ "$l" == "" ] && l=20
tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}
genpasswd 16
uw8CnDVMwC6vOKgW
-A RH-Firewall-1-INPUT -s 192.168.1.0/۲۴ -m state --state NEW -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -s 202.54.1.5/۲۹ -m state --state NEW -p tcp --dport 22 -j ACCEPT
sudo ufw allow from 202.54.1.5/29 to any port 22
pass in on $ext_if inet proto tcp from {192.168.1.0/24, 202.54.1.5/29} to $ssh_server_ip port ssh flags S/SA synproxy state
ListenAddress 192.168.1.5
ListenAddress 202.54.1.5
sshd : 192.168.1.2 172.16.23.12
#!/bin/bash
inet_if=eth1
ssh_port=22
IPT -I INPUT -p tcp --dport ${ssh_port} -i ${inet_if} -m state --state NEW -m recent --set
IPT -I INPUT -p tcp --dport ${ssh_port} -i ${inet_if} -m state --state NEW -m recent --update --seconds 60 --hitcount 5 -j DROP
IPT -A INPUT -i ${inet_if} -p tcp --dport ${ssh_port} -m state --state NEW -m limit --limit 3/min --limit-burst 3 -j ACCEPT
IPT -A INPUT -i ${inet_if} -p tcp --dport ${ssh_port} -m state --state ESTABLISHED -j ACCEPT
IPT -A OUTPUT -o ${inet_if} -p tcp --sport ${ssh_port} -m state --state ESTABLISHED -j ACCEPT
# another one line example
# $IPT -A INPUT -i ${inet_if} -m state --state NEW,ESTABLISHED,RELATED -p tcp --dport 22 -m limit --limit 5/minute --limit-burst 5-j ACCEPT
<abusive_ips> flush)
IPT -N stage1
IPT -A stage1 -m recent --remove --name knock
IPT -A stage1 -p tcp --dport 3456 -m recent --set --name knock2
IPT -N stage2
IPT -A stage2 -m recent --remove --name knock2
IPT -A stage2 -p tcp --dport 2345 -m recent --set --name heaven
IPT -N door
IPT -A door -m recent --rcheck --seconds 5 --name knock2 -j stage2
IPT -A door -m recent --rcheck --seconds 5 --name knock -j stage1
IPT -A door -p tcp --dport 1234 -m recent --set --name knock
IPT -A INPUT -m --state ESTABLISHED,RELATED -j ACCEPT
IPT -A INPUT -p tcp --dport 22 -m recent --rcheck --seconds 5 --name heaven -j ACCEPT
IPT -A INPUT -p tcp --syn -j door
ClientAliveInterval 300
ClientAliveCountMax 0
Banner /etc/issue
----------------------------------------------------------------------------------------------
You are accessing a XYZ Government (XYZG) Information System (IS) that is provided for authorized use only.
By using this IS (which includes any device attached to this IS), you consent to the following conditions:
+ The XYZG routinely intercepts and monitors communications on this IS for purposes including, but not limited to,
penetration testing, COMSEC monitoring, network operations and defense, personnel misconduct (PM),
law enforcement (LE), and counterintelligence (CI) investigations.
+ At any time, the XYZG may inspect and seize data stored on this IS.
+ Communications using, or data stored on, this IS are not private, are subject to routine monitoring,
interception, and search, and may be disclosed or used for any XYZG authorized purpose.
+ This IS includes security measures (e.g., authentication and access controls) to protect XYZG interests--not
for your personal benefit or privacy.
+ Notwithstanding the above, using this IS does not constitute consent to PM, LE or CI investigative searching
or monitoring of the content of privileged communications, or work product, related to personal representation
or services by attorneys, psychotherapists, or clergy, and their assistants. Such communications and work
product are private and confidential. See User Agreement for details.
----------------------------------------------------------------------------------------------
IgnoreRhosts yes
HostbasedAuthentication no
sudo yum erase openssh-server
sudo apt-get remove openssh-server
service iptables restart
service ip6tables restart
#################[ WARNING ]########################
# Do not use any setting blindly. Read sshd_config #
# man page. You must understand cryptography to #
# tweak following settings. Otherwise use defaults #
####################################################
# Supported HostKey algorithms by order of preference.
HostKey /etc/ssh/ssh_host_ed25519_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
# Specifies the available KEX (Key Exchange) algorithms.
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256
# Specifies the ciphers allowed
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
#Specifies the available MAC (message authentication code) algorithms
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
# LogLevel VERBOSE logs user's key fingerprint on login. Needed to have a clear audit track of which key was using to log in.
LogLevel VERBOSE
# Log sftp level file access (read/write/etc.) that would not be easily logged otherwise.
Subsystem sftp /usr/lib/ssh/sftp-server -f AUTHPRIV -l INFO
ssh -Q cipher
ssh -Q cipher-auth
ssh -Q mac
ssh -Q kex
ssh -Q key
sudo sshd –t
sudo sshd –T
sudo systemctl start ssh ## Debian/Ubunt Linux##
sudo systemctl restart sshd.service ## CentOS/RHEL/Fedora Linux##
doas /etc/rc.d/sshd restart ## OpenBSD##
sudo service sshd restart ## FreeBSD##
ما آپتایم وبسایت و تمامی سرویس های شما را در هر شرایطی به صورت 100 درصد تضمین میکنیم!
توشن سرویس دهنده هاست ایرانی با زیرساخت S.O.C جهت کنترل امنیت اطلاعات کاربران
کارشناسان توشن در هر ساعت از شبانه روز آماده خدمت گذاری به مشتریان عزیز می باشند
لطفا پیش از ارسال دیدگاه، چند مورد زیر را مطالعه نمایید:
- دیدگاه خود را به زبان فارسی ارسال نمایید.
- به دیدگاه کاربران دیگر احترام بگذارید، پیامهایی که شامل محتوای توهینآمیز و کلمات نامناسب باشند، تایید نخواهند شد.
- از ارسال لینک سایت های شخصی و ارائه اطلاعات شخصی در متن دیدگاه پرهیز فرمایید.
- موارد مرتبط با بخش پشتیبانی را از طریق مرکز پشتیبانی مطرح فرمایید تا در اسرع وقت بررسی شوند.
خود را درگیر مشکلات هاست و سرور نکنید!
حل این مشکلات را به ما بسپارید و به توسعه سایت و کسب و کار خود بیاندیشید!
مشاوره و فروش: +21 91006996
سوال فنی دارید؟ ارسال تیکت پشتیبانی
دیدگاهتان را بنویسید