㈠ linux里面怎样配置邮件服务器
Sendmail服务器配置
首先,在DNS正向解析上添加一个邮件交换器的名称
这里顺便把dns的测回试也答附上:
启动sendmail
正向主区域配置文件:
修改sendmail的配置文件
vi /etc/mail/sendmail.cf
改成
修改sendmail的配置文件
vi /etc/mail/sendmail.mc
去掉dnl
再添加两行
做输入重定向m4 /etc/mail/sendmail.mc>/etc/mail/sendmail.cf
编辑 /etc/mail/access
执行makemap hash /etc/mail/access.db </etc/mail/access
编辑vi /etc/mail/local-host-names把邮件服务器使用的域名给添加上去
重启sendmail服务
最后给[email protected]发送测试邮件
End。。。
㈡ sendtolinux
濡備綍鍩轰簬Linux鏋惰緒eb寮廠endmail閭浠舵湇鍔″櫒锛
鏂规硶锛氬湪娓歌堝櫒閲岃緭鍏ヨ矾鐢卞櫒鐨勭$悊ip锛屾瘮濡192.168.0.1涓鑸鏄杩欐牱鐨勶紝鎵撳傚笎鍙峰拰瀵嗙爜锛岄夋嫨NAT锛屾垨鑰呯浉搴旂殑绔鍙f槧灏勮彍鍗曘傚湪绔鍙i偅閲岃緭鍏ラ偖浠舵湇鍔″櫒鐨勭鍙25銆傛帴鐫杈撳叆浣犵數鑴戠殑灞鍩熺綉ip
鍦╨inux涓嬶紝濡備綍閰嶇疆sendmail鏈嶅姟鍣锛堟ラわ級锛
sendmail鏄寮婧愰偖浠舵湇鍔″櫒锛岄渶瑕佽嚜宸辨噦鎶鏈锛岄亣鍒伴棶棰樹篃闅捐В鍐炽傚彲浠ヤ娇鐢╱-mail閭浠剁郴缁熴傚畨瑁呯畝鍗曪紝鏈変笓涓氱殑鎶鏈鏀鎸佸府浣犺В绛旈棶棰樸備娇鐢ㄥ拰缁存姢涔熷规槗锛屽彲浠ュ厤璐逛笅杞借瘯鐢
linux甯哥敤鍛戒护nastat锛
Netstat鍛戒护鐢ㄤ簬鏄剧ず鍚勭嶇綉缁滅浉鍏充俊鎭锛屽傜綉缁滆繛鎺ワ紝璺鐢辫〃锛屾帴鍙g姸鎬(InterfaceStatistics)锛宮asquerade杩炴帴锛屽氭挱鎴愬憳(MulticastMemberships)绛夌瓑銆
鎵ц宯etstat鍚庯紝鍏惰緭鍑虹粨鏋滀负
$netstat|more
ActiveInternetconnections(w/oservers)
ProtoRecv-QSend-
tcp0010.0.2.15:ssh10.0.2.2:52091ESTABLISHED
ActiveUNIXdomainsockets(w/oservers)
ProtoRefCntFlagsTypeStateI-NodePath
unix11DGRAM11021/dev/log
unix2DGRAM11556@/org/freedesktop/hal/udev_event
unix2DGRAM8986@/org/kernel/udev/udevd
unix3STREAMCONNECTED17777
unix3STREAMCONNECTED17776
鍦╨inux绯荤粺涓鎬庝箞鏍风粰绯荤粺鐢ㄦ埛鍙戦棶鍊欙紵
writeusername缁欐煇涓鐢ㄦ埛鍙戞秷鎭鐢ㄥ懡浠wall缁欐墍鏈夌敤鎴峰彂娑堟伅銆傜浉褰撲簬writeallwall--sendamessagetoeverybody鈥檚terminal
linux鏈嶅姟涔婳penSSH鏈嶅姟锛
OpenSSH杩欎竴鏈璇鎸囩郴缁熶腑浣跨敤鐨凷ecureShell杞浠剁殑杞浠跺疄鏂姐傜敤浜庡湪杩滅▼绯荤粺涓婂畨鍏ㄨ繍琛宻hell銆傚傛灉鎮ㄥ湪鍙鎻愪緵ssh鏈嶅姟鐨勮繙绋婰inux绯荤粺涓鎷ユ湁鐢ㄦ埛甯愭埛锛屽垯ssh鏄閫氬父鐢ㄦ潵杩滅▼鐧诲綍鍒拌ョ郴缁熺殑鍛戒护銆俿sh鍛戒护涔熷彲鐢ㄤ簬鍦ㄨ繙绋嬬郴缁熶腑杩愯屽懡浠ゃ
甯歌佺殑杩滅▼鐧诲綍宸ュ叿鏈夛細
telnet
ssh
dropbear
telnet//杩滅▼鐧诲綍鍗忚锛23/TCP//涓鑸鐢ㄤ簬娴嬭瘯绔鍙f垨鑰呮帴鍙f槸鍚﹀紑鍚
璁よ瘉鏄庢枃
鏁版嵁浼犺緭鏄庢枃
ssh//SecureSHell锛屽簲鐢ㄥ眰鍗忚锛22/TCP
閫氫俊杩囩▼鍙婅よ瘉杩囩▼鏄鍔犲瘑鐨勶紝涓绘満璁よ瘉
鐢ㄦ埛璁よ瘉杩囩▼鍔犲瘑
鏁版嵁浼犺緭杩囩▼鍔犲瘑
dropbear//宓屽叆寮忕郴缁熶笓鐢ㄧ殑SSH鏈嶅姟鍣ㄧ鍜屽㈡埛绔宸ュ叿锛屼竴鑸搴旂敤浜庢墜鏈轰笂
1.2SSH鐗堟湰
openssh鏈変袱涓鐗堟湰锛屽垎鍒涓簐1鍜寁2锛屽叾鐗圭偣濡備笅锛
v1锛氬熀浜嶤RC-32鍋歁AC锛屾棤娉曢槻鑼冧腑闂翠汉鏀诲嚮
v2锛氬弻鏂逛富鏈哄崗璁閫夋嫨瀹夊叏鐨凪AC鏂瑰紡銆傚熀浜嶥H绠楁硶鍋氬瘑閽ヤ氦鎹锛屽熀浜嶳SA鎴朌SA绠楁硶瀹炵幇韬浠借よ瘉
鍏充簬瀵嗛挜浜ゆ崲
鍗忓晢鐢熸垚瀵嗙爜鐨勮繃绋嬪彨鍋氬瘑閽ヤ氦鎹锛圛nternetKeyExchange锛孖KE锛変娇鐢ㄧ殑鏄疍H鍗忚锛圖iffie-Hellman锛夛細
A(涓绘満)-->B锛堜富鏈猴級
p,g锛堝ぇ绱犳暟锛岀敓鎴愭暟锛夛紝鍦ㄧ綉缁滀腑浼犺緭鐨勶紝鍏寮鐨
A锛氳嚜宸卞彇涓涓闅忔満鏁皒
B锛氳嚜宸卞彇涓涓闅忔満鏁皔
A锛歡^x%p-->B
B锛歡^y%p-->A
A锛(g^y%p)^x=g^yx%p
B锛(g^x%p)^y=g^xy%p
杩欐渶鍚庡緱鍑虹殑g^xy%p灏辨槸鏈缁堢殑瀵嗛挜
1.3SSH璁よ瘉鏂瑰紡
openssh鏈変袱绉嶈よ瘉鏂瑰紡锛屽垎鍒鏄锛
鍩轰簬鍙d护璁よ瘉锛堝嵆瀵嗙爜璁よ瘉锛
鍩轰簬瀵嗛挜璁よ瘉锛堥潪瀵圭О鍔犲瘑銆傛湁涓瀵瑰瘑閽ワ紝鍏閽ワ紙P锛夊拰绉侀挜锛圫锛夛級
1.4openSSH鐨勫伐浣滄ā寮
openSSH鏄鍩轰簬C/S鏋舵瀯宸ヤ綔鐨
鏈嶅姟鍣ㄧ//sshd锛岄厤缃鏂囦欢鍦/etc/ssh/sshd_config
#vim/etc/ssh/sshd_config
#$OpenBSD:sshd_config,v1.1002016/08/1512:32:04naddyExp$
#Thisisthesshdserversystem-wideconfigurationfile.See
#sshd_config(5)formoreinformation.
#ThissshdwascompiledwithPATH=/usr/local/bin:/usr/bin
#_configshippedwith
#
#possible,butleavethemcommented.Uncommentedoptionsoverridethe
#defaultvalue.
#,youhavetotell
#SELinuxaboutthischange.
#semanageport-a-tssh_port_t-ptcp#PORTNUMBER
#
#Port22
#AddressFamilyany
#ListenAddress0.0.0.0
#ListenAddress::
.
.
.
#-userbasis
#MatchUseranoncvs
#X11Forwardingno
#AllowTcpForwardingno
#PermitTTYno
#ForceCommandcvsserver
瀹㈡埛绔
//ssh锛岄厤缃鏂囦欢鍦/etc/ssh/ssh_config
ssh-keygen//瀵嗛挜鐢熸垚鍣
ssh--id//灏嗗叕閽ヤ紶杈撹嚦杩滅▼鏈嶅姟鍣
scp//璺ㄤ富鏈哄畨鍏ㄥ嶅埗宸ュ叿
$OpenBSD:ssh_config,v1.302016/02/2023:06:23sobradoExp$
#Thisisthesshclientsystem-wideconfigurationfile.See
#ssh_config(5)formoreinformation.Thisfileprovidesdefaultsfor
#users,andthevaluescanbechangedinper-userconfigurationfiles
#oronthecommandline.
#:
#1.commandlineoptions
#2.user-specificfile
#3.system-widefile
#.
#Thus,host-
#configurationfile,anddefaultsattheend.
#Site-.Foracomprehensive
#listofavailableoptions,theirmeaningsanddefaults,pleaseseethe
#ssh_config(5)manpage.
#Host*
#ForwardAgentno
#ForwardX11no
#RhostsRSAAuthenticationno
#RSAAuthenticationyes
#PasswordAuthenticationyes
.
.
.
#Sendlocale-relatedenvironmentvariables
SendEnvLANGLC_CTYPELC_NUMERICLC_TIMELC_COLLATELC_MONETARYLC_MESSAGES
SendEnvLC_PAPERLC_NAMELC_ADDRESSLC_TELEPHONELC_MEASUREMENT
SendEnvLC_IDENTIFICATIONLC_ALLLANGUAGE
SendEnvXMODIFIERS
1.5SecureShell绀轰緥
//浠ュ綋鍓嶇敤鎴疯韩浠藉垱寤鸿繙绋嬩氦浜掑紡shell锛岀劧鍚庡湪缁撴潫鏃朵娇鐢╡xit鍛戒护杩斿洖鍒颁箣鍓嶇殑shell
#ssh192.168.112.131
Theauthenticityofhost餘.168.112.131(192.168.112.131)'can'tbeestablished.
//鐢熸垚浜嗕竴涓绠楁硶鏄疭HA256寰楀叕閽
ECDSAkeyfingerprintisSHA256:dyCibeKTgTQDtKrGgYAKVnGsLcR/Necufp4Jvnx0cTc.
ECDSAkeyfingerprintisMD5:bb:a6:d4:16:be:40:d1:d9:ef:6b:89:c9:22:bb:bd:b0.
//闂浣犳槸鍚︿俊浠绘墍杩炴帴寰椾富鏈猴紝涓嶄俊浠诲垯涓嶈繛鎺
(yes/no)?yes
Warning:Permanentlyadded餘.168.112.131'(ECDSA)tothelistofknownhosts.
[email protected]'spassword:
Lastlogin:MonApr114:24:132019from192.168.112.14
//姝ゆ椂浠庣敤鎴峰悕寰楃煡宸茬粡鐧婚檰鍒板彟涓鍙颁富鏈
#
//浠ュ叾浠栫敤鎴疯韩浠斤紙remoteuser锛夊湪閫夊畾涓绘満锛坮emotehost锛変笂杩炴帴鍒拌繙绋媊shell`
[email protected]'spassword:
Lastlogin:MonApr114:24:542019from192.168.112.14
#
//浠ヨ繙绋嬬敤鎴疯韩浠斤紙remoteuser锛夊湪杩滅▼涓绘満锛坮emotehost锛変笂閫氳繃灏嗚緭鍑鸿繑鍥炲埌鏈鍦版樉绀哄櫒鐨勬柟寮忔潵鎵ц屽崟涓鍛戒护
//棣栧厛鐧婚檰涓鍙颁富鏈烘煡鐪嬭嚜宸盜P
#ipasens33
2:ens33:BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscpfifo_faststateUPqlen1000link/ether00:0c:29:8e:77:9bbrdff:ff:ff:ff:ff:ffinet192.168.112.131/24brd192.168.112._lft1191secpreferred_lft1191secinet6fe80::bc68:f1a3:4a1f:87fb/64scopelink
valid_lftforeverpreferred_lftforever
//鍦ㄧ敤鍙︿竴鍙颁富鏈洪氳繃ssh鏉ヨ繙绋嬫墽琛屽懡浠
#[email protected]'/usr/sbin/ipasens33'
[email protected]'spassword:
2:ens33:BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscpfifo_faststateUPqlen1000link/ether00:0c:29:8e:77:9bbrdff:ff:ff:ff:ff:ffinet192.168.112.131/24brd192.168.112._lft1783secpreferred_lft1783secinet6fe80::bc68:f1a3:4a1f:87fb/64scopelink
valid_lftforeverpreferred_lftforever
#
//w鍛戒护鍙浠ユ樉绀哄綋鍓嶇櫥褰曞埌璁$畻鏈虹殑鐢ㄦ埛鍒楄〃銆傝繖瀵逛簬鏄剧ず鍝浜涚敤鎴蜂娇鐢╯sh浠庡摢浜涜繙绋嬩綅缃杩涜屼簡鐧诲綍浠ュ強鎵ц屼簡浣曠嶆搷浣滅瓑鍐呭圭壒鍒鏈夌敤
#ssh192.168.112.131
[email protected]'spassword:
Lastlogin:MonApr114:30:572019from192.168.112.14
//鍦ㄥ垏鎹㈠埌GUI涓绘満浣跨敤w鍛戒护鏌ョ湅鍙浠ョ湅鍒192.168.112.14鐢ㄦ埛鍦ㄧ櫥闄嗕腑
#w14:40:59up4:37,2users,loadaverage:0.00,0.02,0.05
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
rootpts/0192.168.112.110:033.00s0.17s0.01sw
rootpts/1192.168.112.1414:402.00s0.03s0.03s-bash
1.5SSH涓绘満瀵嗛挜
ssh閫氳繃鍏閽ュ姞瀵嗙殑鏂瑰紡淇濇寔閫氫俊瀹夊叏銆傚綋鏌愪竴ssh瀹㈡埛绔杩炴帴鍒皊sh鏈嶅姟鍣ㄦ椂锛屽湪璇ュ㈡埛绔鐧诲綍涔嬪墠锛屾湇鍔″櫒浼氬悜鍏跺彂閫佸叕閽ュ壇鏈銆傝繖鍙鐢ㄤ簬涓洪氫俊娓犻亾璁剧疆瀹夊叏鍔犲瘑锛屽苟鍙楠岃瘉瀹㈡埛绔鐨勬湇鍔″櫒銆
褰撶敤鎴风涓娆′娇鐢╯sh杩炴帴鍒扮壒瀹氭湇鍔″櫒鏃讹紝ssh鍛戒护鍙鍦ㄧ敤鎴风殑/.ssh/known_hosts鏂囦欢涓瀛樺偍璇ユ湇鍔″櫒鐨勫叕閽ャ傚湪姝や箣鍚庢瘡褰撶敤鎴疯繘琛岃繛鎺ユ椂锛屽㈡埛绔閮戒細閫氳繃瀵规瘮/.ssh/known_hosts鏂囦欢涓鐨勬湇鍔″櫒鏉$洰鍜屾湇鍔″櫒鍙戦佺殑鍏閽ワ紝纭淇濅粠鏈嶅姟鍣ㄨ幏寰楃浉鍚岀殑鍏閽ャ傚傛灉鍏閽ヤ笉鍖归厤锛屽㈡埛绔浼氬亣瀹氱綉缁滈氫俊宸查伃鍔鎸佹垨鏈嶅姟鍣ㄥ凡琚鍏ヤ镜锛屽苟涓斾腑鏂杩炴帴銆
杩欐剰鍛崇潃锛屽傛灉鏈嶅姟鍣ㄧ殑鍏閽ュ彂鐢熸洿鏀癸紙鐢变簬纭鐩樺嚭鐜版晠闅滃艰嚧鍏閽ヤ涪澶憋紝鎴栬呭嚭浜庢煇浜涙e綋鐞嗙敱鏇挎崲鍏閽ワ級锛岀敤鎴峰垯闇瑕佹洿鏂板叾~/.ssh/known_hosts鏂囦欢骞跺垹闄ゆ棫鐨勬潯鐩鎵嶈兘澶熻繘琛岀櫥褰曘
//涓绘満ID瀛樺偍鍦ㄦ湰鍦板㈡埛绔绯荤粺涓婄殑~/.ssh/known_hosts涓(瀹剁洰褰曚腑鐨勯殣钘忕洰褰.ssh)
#cat/root/.ssh/known_hosts
192.168.112.131ecdsa-sha2-ayz0bbvSc5be4/rddT4r2q//eg1Z11x05bGjRJfL+8=
//涓绘満瀵嗛挜瀛樺偍鍦⊿SH鏈嶅姟鍣ㄤ笂鐨/etc/ssh/ssh_host_key*涓锛堜篃灏辨槸涓嶆墜鍔ㄧ敓鎴愬瘑閽ョ殑鎯呭喌涓嬩細鑷鍔ㄤ娇鐢ㄨ繖閲岀殑瀵嗛挜锛
#ls/etc/ssh/*key*
/etc/ssh/ssh_host_ecdsa_key/etc/ssh/ssh_host_ecdsa_key.pub/etc/ssh/ssh_host_ed25519_key/etc/ssh/ssh_host_ed25519_key.pub/etc/ssh/ssh_host_rsa_key/etc/ssh/ssh_host_rsa_key.pub
2.閰嶇疆鍩轰簬SSH瀵嗛挜鐨勮韩浠介獙璇
鐢ㄦ埛鍙閫氳繃浣跨敤鍏閽ヨ韩浠介獙璇佽繘琛宻sh鐧诲綍韬浠介獙璇併俿sh鍏佽哥敤鎴蜂娇鐢ㄧ侀挜-鍏閽ユ柟妗堣繘琛岃韩浠介獙璇併傝繖鎰忓懗鐫灏嗙敓鎴愮侀挜鍜屽叕閽ヨ繖涓や釜瀵嗛挜銆傜侀挜鏂囦欢鐢ㄤ綔韬浠介獙璇佸嚟鎹锛屽儚瀵嗙爜涓鏍凤紝蹇呴』濡ュ杽淇濈°傚叕閽ュ嶅埗鍒扮敤鎴峰笇鏈涚櫥褰曠殑绯荤粺锛岀敤浜庨獙璇佺侀挜銆傚叕閽ュ苟涓嶉渶瑕佷繚瀵嗐傛嫢鏈夊叕閽ョ殑ssh鏈嶅姟鍣ㄥ彲浠ュ彂甯冧粎鎸佹湁鎮ㄧ侀挜鐨勭郴缁熸墠鍙瑙g瓟鐨勯棶棰樸傚洜姝わ紝鍙浠ユ牴鎹鎵鎸佹湁鐨勫瘑閽ヨ繘琛岄獙璇併傚傛や竴鏉ワ紝灏变笉蹇呭湪姣忔¤块棶绯荤粺鏃堕敭鍏ュ瘑鐮侊紝浣嗗畨鍏ㄦт粛鑳藉緱鍒颁繚璇併
浣跨敤ssh-keygen鍛戒护鐢熸垚瀵嗙爜銆傚皢浼氱敓鎴愮侀挜/.ssh/id_rsa鍜屽叕閽/.ssh/id_rsa.pub銆
//浣跨敤ssh-keygen鐢熸垚瀵嗛挜鏃堕栧厛浼氳㈤棶浣犲瘑閽ユ枃浠跺瓨鏀剧殑浣嶇疆锛岄粯璁ゆ槸鍦/root/.ssh/id_rsa鍜宨d_rsa.pub
#ssh-keygen
Generatingpublic/privatersakeypair.
Enterfileinwhichtosavethekey(/root/.ssh/id_rsa):
//鎺ョ潃浼氳㈤棶浣犳槸鍚︿负浣犵殑绉侀挜閰嶇疆瀵嗙爜
Enterpassphrase(emptyfornopassphrase):
//鏈鍚庝細鎻愮ず浣犲瘑閽ュ垱寤烘垚鍔燂紝绉侀挜瀛樻斁鍦╥d_rsa,鍏閽ユ斁鍦╥d_rsa.pub
/root/.ssh/id_rsa.
Yourpublickeyhasbeensavedin/root/.ssh/id_rsa.pub.
Thekeyfingerprintis:
SHA256:XFV5J+RPAuuHQZBipB8yUyQ22/QAOWT+z2Tsi+cJcpwroot@CTL
Thekey'srandomartimageis:
//RSA绠楁硶瀵嗛挜涓鑸涓2048浣
+-------+
|.B=*.o+oo.|
|+oOoo.o+oo|
|Boo.ooooo|
|B+.o+|
|S+o..|
|.B.|
|.E+|
|oo.o|
|.o+|
+---------+
娉ㄦ剰锛
鐢熸垚瀵嗛挜鏃讹紝绯荤粺灏嗘彁渚涙寚瀹氬瘑鐮佺殑閫夐」锛屽湪璁块棶绉侀挜鏃跺繀椤绘彁渚涜ュ瘑鐮併傚傛灉绉侀挜琚鍋凤紝闄ら佸彂鑰呬箣澶栫殑鍏朵粬浠讳綍浜哄緢闅句娇鐢ㄨョ侀挜锛屽洜涓哄凡浣跨敤瀵嗙爜瀵瑰叾杩涜屼繚鎶ゃ傝繖鏍凤紝鍦ㄦ敾鍑昏呯牬瑙e苟浣跨敤绉侀挜鍓嶏紝浼氭湁瓒冲熺殑鏃堕棿鐢熸垚鏂扮殑瀵嗛挜瀵瑰苟鍒犻櫎鎵鏈夋秹鍙婃棫瀵嗛挜鐨勫唴瀹广