@sW Internet WzӤHDA̭nOOHjNOpzۤviHsuiJۤvDAåBiҿתyݾޱzFaI]NOAziHb㦳sW Internet qAHݳsunsW Internet AǥѱzDWݳsuAn鸪Ѫ\AnJzDӶiޱu@IɡAzNo{ Linux SnaoIb Unix Like AXG Telnet oӻݳsuAnALA Telnet OHyXzӶǰezާ@ơAwWOȱoӫҭnn}oIoӮɭԴNݭnAѤ@UǰeL{H[Kʧ@Ӷǰeƫʥ] SSH oӻݳsuAnաIoӳ`Aڭ̷| Telnet P SSH oӦAAȱoѦҳI |
[root@test
root]# rpm -qa | grep telnet
telnet-server-krb5-1.2.5-1mdk telnet-client-krb5-1.2.5-1mdk # WO Mandrake 9.0 dҡFΩUO Red Hat 7.2 d telnet-0.17-20 telnet-server-0.17-20 |
[root@test
root]# vi /etc/xinetd.d/telnet
# default: on # description: The telnet server serves telnet sessions; it uses \ # unencrypted username/password pairs for authentication. service telnet { disable = yes<==NOo̡AN yes 令 no YiI flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd log_on_failure += USERID } |
k@GȤ䴩
Red Hat Mandrake tΡG
[root@test root]# service xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ] kGGΪҰʤ觋G
|
[root@test
root]# netstat -tl
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:ssh *:* LISTEN tcp 0 0 *:telnet *:* LISTEN |
step 1: ק@U
/etc/xinetd.d/telnet ɮסG
[root@test root]# vi /etc/xinetd.d/telnet # default: on # description: The telnet server serves telnet sessions; it uses \ # unencrypted username/password pairs for authentication. service telnet { disable = no<==NOo̡AN no 令 yes YiI flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd log_on_failure += USERID } step 2: sҰ
xinet YiG
|
[root@test
root]# telnet localhost
Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Red Hat Linux release 7.2 (Enigma) Kernel 2.4.18 on an i586 login: test <==Jb Password: <==JKXЪ`NIKXä|bùWܥr Last login: Thu Oct 3 11:59:29 from test_inside <==ܤWnJ} You have new mail. <==ۤWnJHӡAO_HcsHIH [test@test test]$ <==o̴NiJF telnet su{ǷFI [test@test test]$ exit <==}o telnet nJI |
[root@test
root]# vi /etc/xinetd.d/telnet
# This file had been modified by VBird 2002/11/04 # First is about inside the network service telnet { disable = no bind = 192.168.1.2 only_from = 192.168.1.0/24 # Wo满ȴѤI instance = UNLIMITED nice = 0 flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/telnetd server_args = -a none log_on_failure += USERID } # Second is
about the outside domain's settings
|
[root@test root]# mv /etc/securetty /etc/securetty.bak |
[root @test
/root]# vi /etc/pam.d/login
#%PAM-1.0 #auth required /lib/security/pam_securetty.so # NWo@[W # ѱI auth required /lib/security/pam_stack.so service=system-auth auth required /lib/security/pam_nologin.so account required /lib/security/pam_stack.so service=system-auth password required /lib/security/pam_stack.so service=system-auth session required /lib/security/pam_stack.so service=system-auth session optional /lib/security/pam_console.so |
/sbin/iptables
-A INPUT -p tcp -i eth0 -s 192.168.0.0/24 --dport 23 -j ACCEPT
/sbin/iptables -A INPUT -p tcp -i eth0 -s 61.xxx.xxx.xxx --dport 23 -j ACCEPT /sbin/iptables -A INPUT -p tcp -i eth0 --dport 23 -j DROP |
[root@test
root]# vi /etc/hosts.allow
in.telnetd: 192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4, 192.168.0.5: allow [root@test root]#
vi
/etc/hosts.deny
|
[root@test
root]# /etc/rc.d/init.d/sshd start
[root@test root]# service sshd start [root@test root]# netstat -tl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:ssh *:* LISTEN |
[root@test
root]# ssh user@hostname
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is 6e:1a:60:d0:ee:d0:7c:91:df:94:de:09:35:7b:08:ba. Please contact your system administrator. Add correct host key in /root/.ssh/known_hosts to get rid of this message. Offending key in /root/.ssh/known_hosts:8 RSA host key for hostname has changed and you have requested strict checking. Host key verification failed. |
sftp @suϥΤ觋G
[root@test root]# sftp test@test.linux.org test@test.linux.org's password: <==пJ test oӨϥΪ̪KXI sftp> <==ݱzJOI |
wﻷD(Server)欰 | |
ܴؿ /etc/test ΨLؿ | cd /etc/test
cd PATH |
CXثeҦbؿUɮשΥؿ | ls
dir |
إߥؿ | mkdir directory |
Rؿ | rmdir directory |
ܥثeҦbؿ | pwd |
ɮשΥؿs | chgrp groupname PATH |
ɮשΥؿ֦ | chown username PATH |
ɮשΥؿv | chmod 644 PATH
𫟺A644 PvI^hݰ¦gI |
إ߳s | ln oldname newname |
RɮשΥؿ | rm PATH |
ɮשΥؿW | rename oldname newname |
}ݥD | exit
bye |
w糧(Client)欰([W l, L pg ) | |
ܴؿ쥻 PATH | lcd PATH |
CXثeҦbؿUɦW | lls |
bإߥؿ | lmkdir |
ܥثeҦbؿ | lpwd |
ɮǿ | |
NɮץѥWǨ컷ݥD | put [ؿɮ] []
put [ؿɮ] pGOoخ榡Ahɮ|mثeݥDؿUI |
NɮץѻݥDU^ | get [ݥDؿɮ] []
get [ݥDؿɮ] YOoخ榡Ahɮ|mbثeҦbؿIiHϥθUΦrAҦpG get * get *.rpm OiH榡I |
psftp: no hostname
specified; use "open host.name" to connect
psftp> |
psftp: no hostname
specified; use "open host.name" to connect
psftp> open test.linux.org login as: test Using username "test". test@test.linux.org's password: Remote working directory is /home/test psftp> |
# 1. SSH
Server ]wA]tϥΪ port աAHΨϥΪKXt觋
Port 22@@@@@@@@@@# SSH w]ϥ 22 o portAz]iHϥΦh port I @@@@@@@@@@@@@ # Yƨϥ port oӳ]wاYiI Protocol 2,1@@@@@@@ # ܪ SSH wAiHO 1 ]iHO 2 A @@@@@@@@@@@@@ # pGnPɤ䴩̡ANnϥ 2,1 oӤjFI #ListenAddress 0.0.0.0@@ # ťDdI|ӨҤlӻApGz IPA @@@@@@@@@@@@@ # OO 192.168.0.100 192.168.2.20 AuQn @@@@@@@@@@@@@ # } 192.168.0.100 ɡANiHgpPU˦G ListenAddress 192.168.0.100 # uťӦ 192.168.0.100 o IP SSHsuC @@@@@@@@@@@@@@@@@@ # pGϥγ]wܡAhw]Ҧ SSH PidFile /var/run/sshd.pid@@@@@@# iHm SSHD o PID ɮסICw] LoginGraceTime 600@@@@ # ϥΪ̳sW SSH server A|X{JKXeA @@@@@@@@@@@@@ # bӵeAbh[ɶS\sW SSH server A @@@@@@@@@@@@@ # N_uIɶI Compression yes@@@@@@# O_iHϥYOHMiHoI @ # 2. D Private Key mɮסAw]ϥΤUɮקYiI HostKey /etc/ssh/ssh_host_key@@@@# SSH version 1 ϥΪp_ HostKey /etc/ssh/ssh_host_rsa_key@@# SSH version 2 ϥΪ RSA p_ HostKey /etc/ssh/ssh_host_dsa_key@@# SSH version 2 ϥΪ DSA p_ # 2.1 version
1 @dz]wI
# 3. nɪTƩmP
daemon W١I
# 4. w]wءInI
# 4.5 nJ᪺ءG
# 4.6 ϥΪ̩ת]wءG
# 5. SFTP
AȪ]wءI
|
[test2@test2
test2]$ ssh-keygen -t rsa <==oӨBJb
Keys
Generating public/private rsa key pair. Enter file in which to save the key (/home/test2/.ssh/id_rsa): Enter passphrase (empty for no passphrase): <==o̫ Enter Enter same passphrase again: <==A@ Enter Your identification has been saved in /home/test2/.ssh/id_rsa. <==oOp_ Your public key has been saved in /home/test2/.ssh/id_rsa.pub.<==oO_ The key fingerprint is: c4:ae:d9:02:d1:ba:06:5d:07:e6:92:e6:6a:c8:14:ba test2@test2.linux.org `NG -t OyϥΦرKXt觋Hzѩڭ̨ϥ RSA A ҥHJ -t rsa Yiإߨ Keys I ~Aإߪ Keys mbaؿU .ssh oӥؿI ݤ@Uo Keys aI [test2 @test2
test2]$ ll ~/.ssh
|
1. b Client
ݥH sftp N_ test WhI
[test2@test2 test2]$ cd ~/.ssh <==ؿ [test2@test2 .ssh]$ sftp test@test.linux.org<==sDW Connecting to test.linux.org... test@test.linux.org's password: <==J test KX sftp> put id_rsa.pub <==N_ Server WhI Uploading id_rsa.pub to /home/test/id_rsa.pub sftp> exit 2. Server
WAN_s authorized_keys ɮפI
|
[test2@test2 test2]$ ssh test@test.linux.org |
oT譱ӵۤiIUڭ̴N@aI
- /etc/ssh/sshd_config
@ӨAoɮתw]شNwgܧƤFIҥHAƹWOӻݭnʥLIOApGzǨϥΪ̤譱U{AiHo˭ץ@ǰDOI
- T root nJGɭԡA\ root Hݳsu觋nJA|O@ӦnDNIҥHoZijjaN root nJvaIҥHAiHק /etc/ssh/sshd_config oɮתeG
p@ӡAH root NH ssh nJoIo٬OnաI ^_^
[root@test root]# vi /etc/ssh/sshd_config
PermitRootLogin no <==NL令 no աI
[root@test root]# /etc/rc.d/init.d/sshd restart
@- \YӸsյnJGǯSpAڭ̷QnϥΪ̥uϥ sendmail, pop3, ftp AOƱLiHݳsuiӡAziHo˰G
1. NoǨϥΪ̳kǦbY@ӯSsդUAҦp nossh oӸsզnFF
2. b /etc/ssh/sshd_config [Jo@GyDenyGroups nosshz
3. sҰ sshd G /etc/rc.d/init.d/sshd restart
o˴NOKաI
@- \YӨϥΪ̵nJG DenyGroups Aϥ DenyUsers YiIѦ sshd_config ]wI
- /etc/hosts.allow /etc/hosts.deny G
oF]O²檺աIѦҡG ²[] @oIMA²檺kNOG@
[root@test /root]# vi /etc/hosts.allow
sshd: 192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4, 192.168.0.5: allow[root@test /root]# vi /etc/hosts.deny
sshd : ALL : spawn (/bin/echo Security notice from host `/bin/hostname`; \
/bin/echo; /usr/sbin/safe_finger @%h ) | \
/bin/mail -s "%d -%h security" root@localhost & \
: twist ( /bin/echo -e "\n\nWARNING connectin not allowed. Your attempt has been logged. \n\n\nĵiz|\nJAzsuN|QAåB@H᪺Ѧ\n\n ". )- iptables
hXhO@]ܦnIҥH]iHϥ iptables IѦҡG²[] @oI
WA SSH ZwAun root nJvADӴN|p@IաIҥHAMiHγ]w iptables AOijwXӺ]w@U /etc/hosts.allow P /etc/hosts.deny I[ooI