¤@³¡³s¤WInternet¤W±ªº±zªºÓ¤H¥D¾÷¡A³Ì«nªº¬O¤°»ò©O¡H¤j·§´N¬O¦p¦óÅý±z¦Û¤v¥i¥H³s½u¶i¤J¦Û¤vªº¥D¾÷¡A¨Ã¥B¶i¦æ©Ò¿×ªº¡y»·ºÝ¾Þ±±¡z¤F§a¡I¤]´N¬O»¡¡A±z¥i¥H¦b¥ô¦ó¨ã¦³³s¤WInternetªº¹q¸£¤¤¡A¥H»·ºÝ³s½u³nÅé³s¤WInternet¡A¨ÃÂǥѱz¥D¾÷¤W±ªº»·ºÝ³s½u¦øªA¾¹³nÅé´£¨Ñªº¥\¯à¡Aª½±µµn¤J±zªº¥D¾÷¨Ó¶i¦æ¾Þ±±ªº¤u§@¡I¦¹®É¡A±z±Nµo²{Linux¦³½ì¤S¦nª±ªº¦a¤èÅo¡I¦b¦´ÁªºUnix Like¾÷¾¹·í¤¤¡A´X¥G³£´£¨ÑTelnet³oÓ»·ºÝ³s½u¦øªA¾¹³nÅé¡A¤£¹L¡ATelnet¥»¨¬O¥H¡y©ú½X¡z¨Ó¶Ç°e±z¾Þ§@ªº¸ê®Æ¡A¦w¥þ¤W±¬Oȱo¨Ó«ä¦Òn¤£n¶}©ñ§o¡I³oÓ®ÉÔ´N¦³»ÝnÁA¸Ñ¤@¤U¶Ç°e¹Lµ{¤¤¥H¥[±K°Ê§@¨Ó¶Ç°e¸ê®Æ«Ê¥]ªºSSH³oÓ»·ºÝ³s½u¦øªA¾¹³nÅé°Õ¡I¥t¥~¡A°£¤F¯Â¤å¦r¤¶±µn¤J¥D¾÷¨Ó¶i¦æ¾Þ±±¤§¥~¡A¦b²{¦bªºLinux distributions·í¤¤¡AÁÙ¥i¥H§Q¥ÎX¬ÛÃöªºªA°È¨ÓÀ°§U§ÚÌ¥H¹Ï§Î¤¶±µn¤J³á¡I«Ü´Î§a¡I^_^ |
[root@linux ~]# rpm -qa | grep telnet telnet-0.17-31.EL4.3 telnet-server-0.17-31.EL4.3 # ¤W±¬O CentOS 4.x ¹w³]ªº®M¥óª©¥»¡C¦pªG¬O¨ä¥Lªº distribution¡A # ÀɦW¥i¯à·|¤£¤Ó¤@¼Ë¡ã¥i§Q¥Î yum ©Î apt µ¥¤è¦¡¨Ó¦w¸Ë³á¡I |
[root@linux ~]# vi /etc/xinetd.d/telnet service telnet { flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd log_on_failure += USERID # disable = yes disable = no # °ò¥»¤W¡A§ï¤W±³o¨â¦æ´N°÷¤F¡I±N disable ³]©w¦¨ no ªí¥Ün±Ò°Ê¡I } |
¶È¾A¦X Red Hat ¨t¦C / Mandriva ¨t¦Cªº¥D¾÷±Ò°Ê¤è¦¡ [root@linux ~]# service xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ] ¾A¦X¦Uª©¥»ªº¥D¾÷±Ò°Ê¤è¦¡ [root@linux ~]# /etc/init.d/xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ] # ¬Y¨Çª©¥»¨Ã¨S¦³ restart ªº¿ï¶µ¡A³oÓ®ÉÔ´N»Ýn¡Gstop ¦A start Åo¡I |
[root@linux ~]# netstat -tlup Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 *:telnet *:* LISTEN 23817/xinetd |
Step 1: קï³]©wÀÉ [root@linux ~]# vi /etc/xinetd.d/telnet service telnet { flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd log_on_failure += USERID disable = yes <== ´N¬O³o¸Ì°Õ¡I±N¥L§ï¦¨ yes ´N¬OÃö³¬¡I } Step 2: «·s±Ò°Ê xinetd ³oÓ super daemon [root@linux ~]# /etc/init.d/xinetd restart |
[root@linux ~]# telnet localhost Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. CentOS release 4.4 (Final) Kernel 2.6.9-42.0.2.EL on an i686 login: dmtsai <== ´N¬O³o¸Ì°Õ¡I½Ð¿é¤J¡y¤@¯ë¡z±b¸¹¡A¤£¯à¥Î root ³á¡I Password: <== ³o¸Ì¿é¤J¸Ó±b¸¹ªº±K½X¡I½Ðª`·N¡A¿é¤J®É¡A¿Ã¹õ¤£·|¦³¥ô¦ó¸ê°T¡I Last login: Fri Jul 1 09:31:21 from 127.0.0.1 <== ¤W¦¸µn¤Jªº¸ê°T¬°¦ó? [dmtsai@linux ~]$ <== ³o¸Ì´N¬O¤w¸gµn¤Jªº¦a¤è¡I¥ç§Y»·ºÝ¥D¾÷¤F¡I [dmtsai@linux ~]$ exit <== ³o¼Ë´N¯à°÷Â÷¶} telnet »P»·ºÝ¥D¾÷«£¡I |
[root@linux ~]# 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 # ¤W±³o¨â¦æ»¡©ú¶È´£¨Ñ¤º³¡ºô°ì¡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 service telnet { disable = no bind = 140.116.142.196 only_from = 140.116.0.0/16 no_access = 140.116.32.{10,26} # ¤W±³o¤T¦æ³]©w¥~³¡¸û¬°ÄY®æªº¨î instance = 10 <==³Ì¦h¤¹³\¦P®É 10 Ó³s½u umask = 022 nice = 10 flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/telnetd server_args = -a none log_on_failure += USERID } |
[root@linux ~]# mv /etc/securetty /etc/securetty.bak |
[root@linux ~]# vi /etc/pam.d/login #%PAM-1.0 #auth required pam_securetty.so <== ´N¬O³o¼Ë¤@¦æ¡A±N¥Lµù¸Ñ§Y¥i¡I auth required pam_stack.so service=system-auth auth required pam_nologin.so account required pam_stack.so service=system-auth password required pam_stack.so service=system-auth # pam_selinux.so close should be the first session rule session required pam_selinux.so close session required pam_stack.so service=system-auth session required pam_loginuid.so session optional pam_console.so # pam_selinux.so open should be the last session rule session required pam_selinux.so multiple open |
iptables -A INPUT -p tcp -i $INIF -s 192.168.0.0/24 --dport 23 -j ACCEPT iptables -A INPUT -p tcp -i $EXTIF -s 61.xxx.xxx.xxx --dport 23 -j ACCEPT iptables -A INPUT -p tcp -i $EXTIF --dport 23 -j DROP |
[root@linux ~]# vi /etc/hosts.allow in.telnetd: 192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4 in.telnetd: 192.168.0.5 [root@linux ~]# vi /etc/hosts.deny in.telnetd : ALL : spawn (/bin/echo Security notice from `/bin/hostname`; \ /bin/echo; /usr/sbin/safe_finger @%h ) | \ /bin/mail -s "%d -%h security" root@localhost & \ : twist ( /bin/echo -e " WARNING connectin not allowed. " ) |
[root@linux ~]# /etc/init.d/sshd restart [root@linux ~]# netstat -tlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 *:ssh *:* LISTEN 24266/sshd |
1. ª½±µµn¤J¨ì¹ï¤è¥D¾÷ªº¤èªk¡G [root@linux ~]# ssh account@hostname # ³s±µ¨ì§Ú̦ۤv¥»¾÷¤W±ªº ssh ªA°È¡I§ó¦h°T®§¡A½Ð man ssh ³á¡I [root@linux ~]# ssh dmtsai@localhost The authenticity of host 'localhost (127.0.0.1)' can't be established. RSA key fingerprint is f8:ae:67:0e:f0:e0:3e:bb:d9:88:1e:c9:2e:62:22:72. Are you sure you want to continue connecting (yes/no)? yes # ¤W±«Ü«n³á¡I°È¥²¶ñ¤J§¹¾ãªº "yes" ¦Ó¤£¬O Y ©Î y ¦Ó¤w¡C Warning: Permanently added 'localhost' (RSA) to the list of known hosts. dmtsai@localhost's password: <== ¦b³o¸Ì¶ñ¤J±K½X¡A¦P¼Ëªº¡A¿Ã¹õ¤£·|¦³°T®§ªº¡I Last login: Fri Jul 1 14:23:27 2005 from localhost.localdomain [dmtsai@linux ~]$ <== Á@¡I¤w¸gµn¤JÅo¡ã [dmtsai@linux ~]$ exit <== ¿é¤J exit ´N¯à°÷Â÷¶}¹ï¤è¥D¾÷Åo¡I 2. ¤£µn¤J¹ï¤è¥D¾÷¡Aª½±µ¦b¹ï¤è¥D¾÷°õ¦æ«ü¥Oªº¤èªk¡G [root@linux ~]# ssh dmtsai@localhost date dmtsai@localhost's password: Tue Nov 22 11:57:27 CST 2005 [root@linux ~]# # ¬Ý¡I¨¥÷ÁÙ¬O root ³á¡I¥u¬O¥H dmtsai ªº¨¥÷¦b»·ºÝ¥D¾÷¤W°õ¦æ¤F¤@Ó«ü¥O¦Ó¤w¡I |
[root@linux ~]# ssh dmtsai@localhost @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 f8:ae:67:0e:f0:a0:3e:aa:d9:77:19:c9:2e:62:22:72. 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:1 RSA host key for localhost has changed and you have requested strict checking. Host key verification failed. |
[root@linux ~]# vi ~/.ssh/known_hosts localhost ssh-rsa AAAAB3NzaC1yc2Euowireffodjoiwjefmoeiwhoqhwupoi t[egmlomowimvoiweo6VpTHTw2/tENp4U7Wn8J6nxYWP36YziFgxtWu4MPSKaRmr E4eUpR1G/zV3TkChRZY5hGUybAreupTVdxCZvJlYvNiejfijoejwiojfijeoiwx5 eRkzvSj7a19vELZ5f8XhzH62E= |
[root@linux ~]# sftp dmtsai@localhost Connecting to localhost... dmtsai@localhost's password: <== ³o¸Ì½Ð¿é¤J±K½X°Ú¡I sftp> <== ³o¸Ì´N¬O¦bµ¥«Ý±z¿é¤J ftp ¬ÛÃö«ü¥Oªº¦a¤è¤F¡I |
°w¹ï»·¤è¥D¾÷(Server)¤§¦æ¬° | |
ÅÜ´«¥Ø¿ý¨ì/etc/test©Î¨ä¥L¥Ø¿ý | cd /etc/test cd PATH |
¦C¥X¥Ø«e©Ò¦b¥Ø¿ý¤UªºÀɦW | ls dir |
«Ø¥ß¥Ø¿ý | mkdir directory |
§R°£¥Ø¿ý | rmdir directory |
Åã¥Ü¥Ø«e©Ò¦bªº¥Ø¿ý | pwd |
§ó§ïÀɮשΥؿý¸s²Õ | chgrp groupname PATH |
§ó§ïÀɮשΥؿý¾Ö¦³ªÌ | chown username PATH |
§ó§ïÀɮשΥؿýªºÅv | chmod 644 PATH ¨ä¤¤¡A644»PÅv¦³Ãö¡I¦^¥h¬Ý°ò¦½g¡I |
«Ø¥ß³sµ²ÀÉ | ln oldname newname |
§R°£ÀɮשΥؿý | rm PATH |
§ó§ïÀɮשΥؿý¦WºÙ | rename oldname newname |
Â÷¶}»·ºÝ¥D¾÷ | exit(or)bye(or)quit |
°w¹ï¥»¾÷(Client)¤§¦æ¬°(³£¥[¤Wl,Lªº¤p¼g) | |
ÅÜ´«¥Ø¿ý¨ì¥»¾÷ªºPATH·í¤¤ | lcd PATH |
¦C¥X¥Ø«e¥»¾÷©Ò¦b¥Ø¿ý¤UªºÀɦW | lls |
¦b¥»¾÷«Ø¥ß¥Ø¿ý | lmkdir |
Åã¥Ü¥Ø«e©Ò¦bªº¥»¾÷¥Ø¿ý | lpwd |
°w¹ï¸ê®Æ¤W¶Ç/¤U¸üªº¦æ¬° | |
±NÀɮץѥ»¾÷¤W¶Ç¨ì»·ºÝ¥D¾÷ | put[¥»¾÷¥Ø¿ý©ÎÀÉ®×][»·ºÝ] put[¥»¾÷¥Ø¿ý©ÎÀÉ®×] ¦pªG¬O³oºØ®æ¦¡¡A«hÀÉ®×·|©ñ¸m¨ì¥Ø«e»·ºÝ¥D¾÷ªº¥Ø¿ý¤U¡I |
±NÀɮץѻ·ºÝ¥D¾÷¤U¸ü¦^¨Ó | get[»·ºÝ¥D¾÷¥Ø¿ý©ÎÀÉ®×][¥»¾÷] get[»·ºÝ¥D¾÷¥Ø¿ý©ÎÀÉ®×] Y¬O³oºØ®æ¦¡¡A«hÀÉ®×·|©ñ¸m¦b¥Ø«e¥»¾÷©Ò¦bªº¥Ø¿ý·í¤¤¡I¥i¥H¨Ï¥Î¸U¥Î¦r¤¸¡A¨Ò¦p¡G get* get*.rpm ¥ç¬O¥i¥Hªº®æ¦¡¡I |
1. ±N¸ê®Æ¥Ñ¥»¾÷¤W¶Ç¨ì»·ºÝ¥D¾÷¤W¥h
[root@linux ~]# scp /etc/crontab dmtsai@localhost:/home/dmtsai/
dmtsai@localhost's password: <== ³o¸Ì½Ð¿é¤J±K½X°Ú¡I
crontab 100% 620 0.6KB/s 00:00
# ³oÓ¨Ò¤l¦b»¡©ú¡A§Ú±N¥»¾÷¥Ø¿ýªº /etc/crontab ³oÓÀɮ׶ǰeµ¹ dmtsai
# ³oӨϥΪ̡A¦Ó³oӨϥΪ̬O¦b "localhost" ¨º³¡¥D¾÷¤W±³á¡I
# ¥J²Ó¬Ý¤@¤U¡A·|¦³¤@Ӷǿé¸ê®Æªº°T®§¶]¥X¨Ó³á¡I
2. ±N¸ê®Æ¥Ñ»·ºÝ¥D¾÷¤U¸ü¨ì¥»¾÷¤W¡I
[root@linux ~]# scp dmtsai@localhost:~/.bashrc .
# ³oÓ¨Ò¤l«h¬O¦b»¡©ú¡A§Ún±N localhost ¨º³¡¾÷¾¹¤Wªº dmtsai ³oÓ¤H¡A
# ¥L®a¥Ø¿ý¤Uªº .bashrc ½Æ»s¨ì§Úªº¾÷¾¹¤W¡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: dmtsai Using username "dmtsai". dmtsai@linux.dmtsai.tw's password: Remote working directory is /home/dmtsai psftp> <== ³o¸Ì´N¦bµ¥«Ý±z¿é¤J FTP ªº«ü¥O¤F¡I |
[root@linux ~]# vi /etc/ssh/sshd_config # 1. Ãö©ó SSH Server ªº¾ãÅé³]©w¡A¥]§t¨Ï¥Îªº port °Õ¡A¥H¤Î¨Ï¥Îªº±K½Xºtºâ¤è¦¡ # ¥ý¯d·N¤@¤U¡A¦b¹w³]ªºÀɮפº¡A¥un¬O³Qµù¸Ñªº³]©wÈ(#)¡A§Y¬°¡y¹w³]È¡I¡z Port 22 # SSH ¹w³]¨Ï¥Î 22 ³oÓport¡A¤]¥i¥H¨Ï¥Î¦hÓport¡A§Y«½Æ¨Ï¥Î port ³oÓ³]©w¶µ¥Ø¡I # ¨Ò¦p·Qn¶}©ñ sshd ¦b 22 »P 443 ¡A«h¦h¥[¤@¦æ¤º®e¬°¡G # Port 443 # ³o¼Ë´N¦n¤F¡I¤£¹L¡A¤£«Øijקï port number °Õ¡I Protocol 1,2 # ¿ï¾Üªº SSH ¨ó©wª©¥»¡A¥i¥H¬O 1 ¤]¥i¥H¬O 2 ¡A # ¦pªGn¦P®É¤ä´©¨âªÌ¡A´N¥²¶·n¨Ï¥Î 2,1 ³oÓ¤À¹j¤F(Protocol 1,2)¡I # ¥Ø«e§ÚÌ·|«Øij±z¡Aª½±µ¨Ï¥Î Protocol 2 §Y¥i¡I #ListenAddress 0.0.0.0 # ºÊÅ¥ªº¥D¾÷¤¶±¥d¡IÁ|Ó¨Ò¤l¨Ó»¡¡A¦pªG±z¦³¨âÓ IP¡A # ¤À§O¬O 192.168.0.100 ¤Î 192.168.2.20 ¡A¨º»ò¥u·Qn # ¶}©ñ 192.168.0.100 ®É¡A´N¥i¥H¼g¦p¦P¤U±ªº¼Ë¦¡¡G ListenAddress 192.168.0.100 # ¥uºÊÅ¥¨Ó¦Û 192.168.0.100 ³oÓ IP ªºSSH³s½u¡C # ¦pªG¤£¨Ï¥Î³]©wªº¸Ü¡A«h¹w³]©Ò¦³¤¶±§¡±µ¨ü SSH #PidFile /var/run/sshd.pid # ¥i¥H©ñ¸m SSHD ³oÓ PID ªºÀɮסI¥ª¦C¬°¹w³]È #LoginGraceTime 2m # ·í¨Ï¥ÎªÌ³s¤W SSH server ¤§«á¡A·|¥X²{¿é¤J±K½Xªºµe±¡A¦b¸Óµe±¤¤¡A # ¦b¦h¤[®É¶¡¤º¨S¦³¦¨¥\³s¤W SSH server ¡A´NÂ_½u¡IYµL³æ¦ì«h¹w³]®É¶¡¬°¬í¡I #Compression yes # ¬O§_¥i¥H¨Ï¥ÎÀ£ÁY«ü¥O¡H·íµM¥i¥HÅo # 2. »¡©ú¥D¾÷ªº Private Key ©ñ¸mªºÀɮסA¹w³]¨Ï¥Î¤U±ªºÀɮקY¥i¡I #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Æ_ # ÁÙ°O±o§Ú̦b¥D¾÷ªº SSH ³s½u¬yµ{¸Ì±½Í¨ìªº¡A³o¸Ì´N¬O Host Key ¡ã # 2.1 Ãö©ó version 1 ªº¤@¨Ç³]©w¡I #KeyRegenerationInterval 1h # ¥Ñ«e±³s½uªº»¡©ú¥i¥Hª¾¹D¡A version 1 ·|¨Ï¥Î server ªº Public Key ¡A # ¨º»ò¦pªG³oÓ Public Key ³Q°½ªº¸Ü¡A°Z¤£§¹³J¡H©Ò¥H»Ýn¨C¹j¤@¬q®É¶¡ # ¨Ó«·s«Ø¥ß¤@¦¸¡I³o¸Ìªº®É¶¡¬°¬í¡I¤£¹L§Ú̳q±`³£¶È¨Ï¥Î version 2 ¡A # ©Ò¥H³oÓ³]©w¥i¥H³Q©¿²¤³á¡I #ServerKeyBits 768 # ¨S¿ù¡I³oÓ´N¬O Server key ªºªø«×¡I¥Î¹w³]ȧY¥i¡C # 3. Ãö©óµn¿ýÀɪº°T®§¸ê®Æ©ñ¸m»P daemon ªº¦WºÙ¡I SyslogFacility AUTHPRIV # ·í¦³¤H¨Ï¥Î SSH µn¤J¨t²Îªº®ÉÔ¡ASSH·|°O¿ý¸ê°T¡A³oÓ¸ê°Tn°O¿ý¦b¤°»ò daemon name # ©³¤U¡H¹w³]¬O¥H AUTH ¨Ó³]©wªº¡A§Y¬O /var/log/secure ¸Ì±¡I¤°»ò¡H§Ñ°O¤F¡I # ¦^¨ì Linux °ò¦ ¥h½¤@¤U¡C¨ä¥L¥i¥Îªº daemon name ¬°¡GDAEMON,USER,AUTH, # LOCAL0,LOCAL1,LOCAL2,LOCAL3,LOCAL4,LOCAL5, #LogLevel INFO # µn¿ý°O¿ýªºµ¥¯Å¡I¼K¼K¡I¥ô¦ó°T®§¡I¦P¼Ëªº¡A§Ñ°O¤F´N¦^¥h°Ñ¦Ò¡I # 4. ¦w¥þ³]©w¶µ¥Ø¡I·¥«n¡I # 4.1 µn¤J³]©w³¡¤À PermitRootLogin no # ¬O§_¤¹³\ root µn¤J¡I¹w³]¬O¤¹³\ªº¡A¦ý¬O«Øij³]©w¦¨ no¡I #UserLogin no # ¦b SSH ©³¤U¥»¨Ó´N¤£±µ¨ü login ³oÓµ{¦¡ªºµn¤J¡I #StrictModes yes # ·í¨Ï¥ÎªÌªº host key §ïÅܤ§«á¡AServer ´N¤£±µ¨ü³s½u¡A¥i¥H©è¾×³¡¤Àªº¤ì°¨µ{¦¡¡I #RSAAuthentication yes # ¬O§_¨Ï¥Î¯Âªº RSA »{ÃÒ¡I¡H¶È°w¹ï version 1 ¡I #PubkeyAuthentication yes # ¬O§_¤¹³\ Public Key ¡H·íµM¤¹³\°Õ¡I¶È°w¹ï version 2 #AuthorizedKeysFile .ssh/authorized_keys # ¤W±³oÓ¦b³]©wYn¨Ï¥Î¤£»Ýn±K½Xµn¤Jªº±b¸¹®É¡A¨º»ò¨ºÓ±b¸¹ªº¦s©ñÀɮשҦbÀɦW¡I # ³oÓ³]©wÈ«Ü«n³á¡IÀɦWµ¹¥L°O¤@¤U¡I # 4.2 »{ÃÒ³¡¤À #RhostsAuthentication no # ¥»¾÷¨t²Î¤£¨Ï¥Î .rhosts¡A¦]¬°¶È¨Ï¥Î .rhosts¤Ó¤£¦w¥þ¤F¡A©Ò¥H³o¸Ì¤@©wn³]©w¬° no #IgnoreRhosts yes # ¬O§_¨ú®ø¨Ï¥Î ~/.ssh/.rhosts ¨Ó°µ¬°»{ÃÒ¡I·íµM¬O¡I #RhostsRSAAuthentication no # # ³oӿﶵ¬O±Mªùµ¹ version 1 ¥Îªº¡A¨Ï¥Î rhosts Àɮצb /etc/hosts.equiv # °t¦X RSA ºtºâ¤è¦¡¨Ó¶i¦æ»{ÃÒ¡I¤£n¨Ï¥Î°Ú¡I #HostbasedAuthentication no # ³oÓ¶µ¥Ø»P¤W±ªº¶µ¥ØÃþ¦ü¡A¤£¹L¬Oµ¹ version 2 ¨Ï¥Îªº¡I #IgnoreUserKnownHosts no # ¬O§_©¿²¤®a¥Ø¿ý¤ºªº ~/.ssh/known_hosts ³oÓÀɮשҰO¿ýªº¥D¾÷¤º®e¡H # ·íµM¤£n©¿²¤¡A©Ò¥H³o¸Ì´N¬O no °Õ¡I PasswordAuthentication yes # ±K½XÅçÃÒ·íµM¬O»Ýnªº¡I©Ò¥H³o¸Ì¼g yes Åo¡I #PermitEmptyPasswords no # Y¤W±¨º¤@¶µ¦pªG³]©w¬° yes ªº¸Ü¡A³o¤@¶µ´N³Ì¦n³]©w¬° no ¡A # ³oÓ¶µ¥Ø¦b¬O§_¤¹³\¥HªÅªº±K½Xµn¤J¡I·íµM¤£³\¡I ChallengeResponseAuthentication no # ¤¹³\¥ô¦óªº±K½X»{ÃÒ¡I©Ò¥H¡A¥ô¦ó login.conf ³W©wªº»{ÃҤ覡¡A§¡¥i¾A¥Î¡I # ¦ý¥Ø«e§Ṳ́ñ¸û³ßÅw¨Ï¥Î PAM ¼Ò²ÕÀ°¦£ºÞ²z»{ÃÒ¡A¦]¦¹³oӿﶵ¥i¥H³]©w¬° no ³á¡I UsePAM yes # §Q¥Î PAM ºÞ²z¨Ï¥ÎªÌ»{ÃÒ¦³«Ü¦h¦n³B¡A¥i¥H°O¿ý»PºÞ²z¡C # ©Ò¥H³o¸Ì§ÚÌ«Øij±z¨Ï¥Î UsePAM ¥B ChallengeResponseAuthentication ³]©w¬° no ¡@ # 4.3 »P Kerberos ¦³Ãöªº°Ñ¼Æ³]©w¡I¦]¬°§Ų́S¦³ Kerberos ¥D¾÷¡A©Ò¥H©³¤U¤£¥Î³]©w¡I #KerberosAuthentication no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes #KerberosTgtPassing no ¡@ # 4.4 ©³¤U¬O¦³Ãö¦b X-Window ©³¤U¨Ï¥Îªº¬ÛÃö³]©w¡I X11Forwarding yes #X11DisplayOffset 10 #X11UseLocalhost yes # 4.5 µn¤J«áªº¶µ¥Ø¡G PrintMotd no # µn¤J«á¬O§_Åã¥Ü¥X¤@¨Ç¸ê°T©O¡H¨Ò¦p¤W¦¸µn¤Jªº®É¶¡¡B¦aÂIµ¥µ¥¡A¹w³]¬O yes # ¥ç§Y¬O¦C¦L¥X /etc/motd ³oÓÀɮתº¤º®e¡C¦ý¬O¡A¦pªG¬°¤F¦w¥þ¡A¥i¥H¦Ò¼{§ï¬° no ¡I PrintLastLog yes # Åã¥Ü¤W¦¸µn¤Jªº¸ê°T¡I¥i¥H°Ú¡I¹w³]¤]¬O yes ¡I KeepAlive yes # ¤@¯ë¦Ó¨¥¡A¦pªG³]©w³o¶µ¥Øªº¸Ü¡A¨º»ò SSH Server ·|¶Ç°eKeepAlive ªº°T®§µ¹ # ClientºÝ¡A¥H½T«O¨âªÌªº³s½u¥¿±`¡I¦b³oÓ±¡ªp¤U¡A¥ô¦ó¤@ºÝ¦º±¼«á¡ASSH¥i¥H¥ß¨èª¾¹D¡I # ¦Ó¤£·|¦³»ø«Íµ{§Çªºµo¥Í¡I UsePrivilegeSeparation yes # ¨Ï¥ÎªÌªºÅv³]©w¶µ¥Ø¡I´N³]©w¬° yes §a¡I MaxStartups 10 # ¦P®É¤¹³\´XÓ©|¥¼µn¤Jªº³s½uµe±¡H·í§Ú̳s¤W SSH ¡A¦ý¬O©|¥¼¿é¤J±K½X®É¡A # ³oÓ®ÉÔ´N¬O§Ú̩ҿתº³s½uµe±°Õ¡I¦b³oÓ³s½uµe±¤¤¡A¬°¤F«OÅ@¥D¾÷¡A # ©Ò¥H»Ýn³]©w³Ì¤jÈ¡A¹w³]³Ì¦h¤QÓ³s½uµe±¡A¦Ó¤w¸g«Ø¥ß³s½uªº¤£pºâ¦b³o¤QÓ·í¤¤ # 4.6 Ãö©ó¨Ï¥ÎªÌ©è¾×ªº³]©w¶µ¥Ø¡G DenyUsers * # ³]©w¨ü©è¾×ªº¨Ï¥ÎªÌ¦WºÙ¡A¦pªG¬O¥þ³¡ªº¨Ï¥ÎªÌ¡A¨º´N¬O¥þ³¡¾×§a¡I # Y¬O³¡¤À¨Ï¥ÎªÌ¡A¥i¥H±N¸Ó±b¸¹¶ñ¤J¡I¨Ò¦p¤U¦C¡I DenyUsers test DenyGroups test # »P DenyUsers ¬Û¦P¡I¶È©è¾×´XÓ¸s²Õ¦Ó¤w¡I # 5. Ãö©ó SFTP ªA°Èªº³]©w¶µ¥Ø¡I Subsystem sftp /usr/lib/ssh/sftp-server |
[test2@test2 ~]$ ssh-keygen -t rsa <==³oÓ¨BÆJ¦b²£¥Í Key pair Generating public/private rsa key pair. Enter file in which to save the key (/home/test2/.ssh/id_rsa): <==³o¸Ì«ö¤UEnter 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. <==³o¬O¨pÆ_ Your public key has been saved in /home/test2/.ssh/id_rsa.pub. <==³o¬O¤½Æ_ The key fingerprint is: c4:ae:d9:02:d1:ba:06:5d:07:e6:92:e6:6a:c8:14:ba test2@test2.linux.org # ª`·N¡G -t «üªº¬O¡y¨Ï¥Î¦óºØ±K½Xºtºâ¤è¦¡¡H¡z¥Ñ©ó§Ų́ϥΠRSA ¡A # ©Ò¥Hª½±µ¿é¤J -t rsa §Y¥i«Ø¥ß¨â¤ä Keys ¡I # ¦¹¥~¡A«Ø¥ßªº¨â§â Keys ³£©ñ¸m¦b®a¥Ø¿ý¤Uªº .ssh ³oӥؿý¤¤¡I # ¹î¬Ý¤@¤U³o¨â§â Keys §a¡I [test2@test2 ~]$ ll ~/.ssh total 12 -rw------- 1 test2 test2 887 Nov 12 22:36 id_rsa -rw-r--r-- 1 test2 test2 233 Nov 12 22:36 id_rsa.pub -rw-r--r-- 1 test2 test2 222 Oct 31 11:20 known_hosts |
1. ¥ý¦b Client ºÝ¥H sftp ±N¤½Æ_¥á¨ì test ¤W±¥h¡I [test2@test2 ~]$ cd ~/.ssh [test2@test2 .ssh]$ scp id_rsa.pub test@192.168.0.2:~/ test@192.168.0.2's password: id_rsa.pub 100% 233 0.2KB/s 00:00 2. ¨ì Server ¤W±¡A±N¤½Æ_Âà¦s¨ì authorized_keys Àɮפ¤¡I [test@linux ~]$ cd ~/.ssh [test@linux .ssh]$ cat ../id_rsa.pub >> authorized_keys |
[test2@test2 ~]$ ssh test@linux.dmtsai.tw |
[root@linux ~]# vi /etc/ssh/sshd_config PermitRootLogin no <== ±N¥L§ï¦¨ no §a¡I [root@linux ~]# /etc/init.d/sshd restart |
[root@linux ~]# 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@linux ~]# 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 " WARNING connectin not allowed.". ) |
DisplayManager.requestPort: 0 |
!DisplayManager.requestPort: 0 |
1. ¥ýÅý kdm ¤ä´© xdmcp ¼Ò¦¡ [root@linux ~]# cd /etc/X11/xdm [root@linux xdm]# vi kdmrc [Xdmcp] Enable=1 # ¤j¬ù¬O¦b 70 ¦æ¥ª¥k¡C¤£nÃhºÃ¡I¯uªº¥un³o¼Ë´N¦n¤F¡I 2. Åý client ¥i¥H³z¹L X ¨Óµn¤J¨t²Î¡I»PÅv¦³Ãöªº³]©w [root@linux xdm]# vi Xaccess * # ¬°¤F¦w¥þ©Ê¤W±ªº»Ýn¡A·Qnµn¤J X ªº¸Ü¡A±on³q¹L³oÓÀɮתºÅçÃÒ¤~¦æ¡C # §ä¨ì¤W±³o¤@¦æ¡A¦pªG¨S¦³³o¤@¦æªº¸Ü(¾ã¦æ¥u¦³¤@Ó * )¡A # ´N¦Û¦æ¥[¤J¡C³oªí¥Ü¡y¤£½×¨Ó¦Ûþ¸Ì¡A§Ú³£±µ¨ü X µn¤J¡zªº·N«ä¡I 3. ±Ò°Ê kdm ³á¡I [root@linux xdm]# /etc/init.d/xfs start # ´N¦p¦P§Ṳ́W±´£¨ìªº¡A kdm °õ¦æ«á¡A¥i¯àªº¸Ü¡A·|¦b¥»¾÷ºÝ±Ò°Ê¤@Ó X server ªº¡A # ¦Ó§Ú̳o¤@ª©ªº Xorg n¶¶§Qªº±Ò°Ê¡A±on¥ý±Ò¥Î X font Server ¤~¦æ¡A # §_«hªº¸Ü¡A±z´N±on¨ì /etc/X11/Xorg.conf ¸Ì±¥h³]©w¦n¨CÓ¦r«¬ªº¸ô®|¤~¦æ¡C [root@linux xdm]# kdm [root@linux xdm]# netstat -tlunp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 5920/X tcp 0 0 :::6000 :::* LISTEN 5920/X udp 0 0 :::177 :::* 5918/kdm # n¬Ý¨ì¦³ 177 ªº udp port ¥X²{¤~¦æ¡ã ¦]¬°¨º¬O xdmcp ¨ó©wªººÊÅ¥°ð¤f¡C # ¤£¹L¡A¦pªGn¬Ý¬Ý¬O§_¦³¦¨¥\±Ò°Ê X ªº¸Ü¡A´N±on¬d¾\ 6000 ³oÓ port Åo¡ã # ¦pªG¨S¦³¬Ý¨ì port 6000 ªº¸Ü¡A½Ð¬d¾\ /var/log/Xorg.0.log ³á¡I # ¦pªG·Qn³]©w¶}¾÷´N¦Û°Ê°õ¦æªº¸Ü¡A¥i¥H§Q¥Î chkconfig ¥[¤J xfs ¡A # ¤]¥i¥H±N kdm ³oÓ«ü¥O¼g¨ì /etc/rc.d/rc.local ³oÓÀɮפ¤¡ã |
0. ½Ð°È¥²n¦b X Window ·í¤¤¡A¶i¤J X Window ªº¤è¦¡¦³¡G [root@client ~]# startx # ©Î [root@client ~]# init 5 ¡@ 1. ¦b X Window ªºµe±·í¤¤¡A±Ò¥Î¤@Ó shell ¡AµM«á¿é¤J¡G [root@client ~]# xhost + 192.168.1.100 192.168.1.100 being added to access control list # °²³]§Úè診³¡ Linux ¥D¾÷ªº IP ¬° 192.168.1.100 [root@client ~]# init 3 <== Ãö³¬ X Server 2. ¦b¤å¦r¤¶±¤U¿é¤J¡G [root@client ~]# X -query 192.168.1.100 # ¶i¤J X Window Åo¡I |
[root@linux xdm]# killall -9 kdm [root@linux xdm]# /etc/init.d/xfs stop |
1. ¥ýÅý kdm ¤ä´© xdmcp ¼Ò¦¡ [root@linux ~]# cd /etc/X11/xdm [root@linux xdm]# vi kdmrc [Xdmcp] Enable=1 2. Åý client ¥i¥H³z¹L X ¨Óµn¤J¨t²Î¡I»PÅv¦³Ãöªº³]©w [root@linux xdm]# vi Xaccess * 3. ±Ò°Ê kdm ³á¡I [root@linux xdm]# /etc/init.d/xfs start [root@linux xdm]# kdm [root@linux xdm]# netstat -tlunp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 5920/X tcp 0 0 :::6000 :::* LISTEN 5920/X udp 0 0 :::177 :::* 5918/kdm # n¬Ý¨ì¦³ 177 ªº udp port »P port 6000 ¤~¦æ¡F # ¦pªG¨S¦³¬Ý¨ìªº¸Ü¡A´N±on¬d¸ß©³¤U´XÓÀɮתº¤º®e¡A¬Ý¬Ý¿ù»~°T®§¤F¡I # a. ¥²¶·¬d¾\ netstat -tlunp # b. ¥²¶·¬d¾\ /var/log/Xorg.log.0 # c. ¥²¶·¬d¾\ /var/log/messages # d. ¥²¶·¬d¾\ /var/log/kdm.log 4. ¥Î¬Y¨¥÷«Ø¥ß passfile µ¹ VNC ³s½u®É¨Ï¥Î # ¦]¬° VNC ¶}ªº¨CÓ port ³£¬Oµ¹¬Y¯S©w¨Ï¥ÎªÌµn¤Jªº¡A¦]¦¹¡A # ¨CÓ VNC server ³£·|±Ò¥Î¦Û¤vªº port ©O¡ã¾Ú»¡³Ì¤j¥i¶}©ñ¨ì 10 Ó¡ã # ³¾ô³o¸Ì°²³]§Q¥Î dmtsai ³oӨϥΪ̨Ӱõ¦æ VNC ¡A¨º»ò¥L´N¥²¶·n¦³©³¤U´XӰʧ@¡G 4.1 «Ø¥ß³s½u¥Î±K½X [root@linux xdm]# su dmtsai [dmtsai@linux xdm]$ vncpasswd Password: <== ³o¸Ì½Ð¿é¤J±K½X Verify: <== ¦A¿é¤J¤@¦¸¡ã # ¯S§Oª`·N¡A¬°¤F¦w¥þ°_¨£¡A±K½Xªºªø«×¬O¦³¨îªº¡I # ¦Ü¤Ön¤j©ó¤»Ó¦r¤¸¡A¥B¤£¯à»P±b¸¹¬Û¦P¡ã # ±K½X«Ø¥ß«á¡A·|¦b /home/dmtsai/.vnc/passwd ³oÓÀɮפ¤°O¿ý¤F§Aªº±K½X¡ã # ¦P®É¡A¦b³oӥؿý¤U¡AÁÙ¦³³]©wÀÉ xstartup ¥i¥H§Q¥Î³á¡I ^_^ 4.2 קï³]©wÀÉ xstartup [dmtsai@linux xdm]$ vi /home/dmtsai/.vnc/xstartup # ±N³oÓÀɮפºªº©Ò¦³¸ê®Æ³q³qµ¹¥Lµù¸Ñ±¼¡ã¤£»Ýn«O¯d¡ã 4.3 Â÷¶}¦¹¤@¨¥÷¨Ï¥ÎªÌªºµe± [dmtsai@linux xdm]$ exit 5. קï /etc/sysconfig/vncserver Àɮפº®e # ³oÓÀɮ׬O FC4 ¹w³]ªº±Ò°Ê VNC ªºÅª¨úÀÉ¡A©Ò¥H§ÚÌ¥i¥Hקï¥L¡ã [root@linux xdm]# vi /etc/sysconfig/vncservers # ±N쥻ªº¸ê®Æ§ï¦¨³o¼Ë¡G VNCSERVERS="2:dmtsai" VNCSERVERARGS[2]="-geometry 800x600 -query localhost" # ·N«ä¬O»¡¡A§ÚÌn±Ò°Ê¤@Ó VNC ¦b port 5900+2 §Y 5902 ªº·N«ä¡A 6. ±Ò°Ê VNC server [root@linux xdm]# /etc/init.d/vncserver start # ¦¹®É¦b /home/dmtsai/.vnc/ ¸Ì±À³¸Ó·|¦³´XÓÀÉ®×±zÀ³¸Ónª`·Nªº¡A # ³Ì«nªº´N¬O dmtasi.linux.dmtsai.tw:2.log ³oÓÀɮסAÀɦWªº¥Ñ¨Ó¬O¡G # username.hostname.domainname:[port number].log ¡A¦]¬°§Ú̬O±Ò¥Î 5902 ¡A # ©Ò¥H´N¦³ :2.log ªºªþÀɦW°Õ¡ã°È¥²¬Ý¨ì¸Ì±¨S¦³¿ù»~¤~¦æ³á¡ã # ¦pªGµo²{§ä¤£¨ì/usr/X11R6/lib/X11/xserver/SecurityPolicy ªº¿ù»~¡A¥ý²¤¹L¤£nºò¡ã 7. ¬d¾\³]©wµ²ªG [root@linux xdm]# netstat -tulnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:5802 0.0.0.0:* LISTEN 15287/Xvnc tcp 0 0 0.0.0.0:5902 0.0.0.0:* LISTEN 15287/Xvnc tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 15019/X tcp 0 0 0.0.0.0:6002 0.0.0.0:* LISTEN 15287/Xvnc tcp 0 0 :::6000 :::* LISTEN 15019/X tcp 0 0 :::6002 :::* LISTEN 15287/Xvnc udp 0 0 0.0.0.0:32924 0.0.0.0:* 15287/Xvnc udp 0 0 :::177 :::* 15017/kdm |
[root@linux ~]# vncserver :3 You will require a password to access your desktops. Password: <== ´N¿é¤J±K½X§a¡I Verify: <== ¦A¿é¤J±K½X§a¡I New 'dmtsai.linux.dmtsai.tw:3 (dmtsai)' desktop is dmtsai.linux.dmtsai.tw:3 Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/dmtsai.linux.dmtsai.tw:3.log |
[root@linux ~]# vncserver -kill :3 |
[root@linux ~]# vi /etc/X11/xorg.conf (©Î XF86Config) Section "Module" .... Load "vnc" EndSection # ¦b Module ³oÓ section ·í¤¤¥[¤J vnc ³oÓ¼Ò²Õ§Y¥i Section "Screen" Identifier "Screen0" Device "Videocard0" Monitor "Monitor0" Option "passwordFile" "/etc/vnc/passwd" DefaultDepth 16 ...... EndSection # °²³]±zªº vnc ±K½XÀɮשñ¸m¦b /etc/vnc/passwd ¸ÌÀY¡A # ³oÓ®ÉÔ´N±on±N±K½XÀɤº®e¼g¨ì Screen ³oÓ section ·í¤¤¤F |
[root@linux ~]# vi /etc/xinetd.d/rsh service shell { disable = no socket_type = stream wait = no user = root log_on_success += USERID log_on_failure += USERID server = /usr/sbin/in.rshd } # ¨S¿ù¡I¥un±N disable §ï¦¨ no §Y¥i¡I [root@linux ~]# /etc/init.d/xinetd restart [root@linux ~]# netstat -tlnp | grep 514 Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:514 0.0.0.0:* LISTEN 23369/xinetd # ¦³¬Ý¨ì 514 ªº port ¥X²{´N¹ï¤F¡I |
[root@linux ~]# vi /etc/hosts 127.0.0.1 localhost localhost.localdomain 192.168.1.2 rsh.server rshserver 192.168.1.100 rsh.client rshclient # ¤W±¶È¦³¨â³¡¥D¾÷¡A°²³] RSH server ªº IP ¬O 192.168.1.2 °Õ¡I |
[root@linux ~]# vi /etc/hosts.equiv rsh.client dmtsai # ³oÓÀɮתº®æ¦¡¬O [hostname] [username] # ±N§An¶}©ñªº¨Ï¥ÎªÌ»P¬Y¥D¾÷µ¹¥L¹ïÀ³¦n¼g¤W¥h§Y¥i¡I |
[root@linux ~]# vi ~dmtsai/.rhosts rsh.client |
[root@linux ~]# vi /etc/skel/.rhosts rsh.client |
[root@linux ~]# vi /etc/pam.d/rsh #%PAM-1.0 # For root login to succeed here with pam_securetty, "rsh" must be # listed in /etc/securetty. auth required pam_nologin.so #auth required pam_securetty.so auth required pam_env.so auth required pam_rhosts_auth.so account required pam_stack.so service=system-auth session required pam_stack.so service=system-auth |
[root@linux ~]# vi /etc/securetty .....(¬Ù²¤)..... rsh |
[dmtsai@rshclient ~]$ rsh [-l »·ºÝ±b¸¹] [»·ºÝ¥D¾÷¦W] [»·ºÝ¥D¾÷«ü¥O] °Ñ¼Æ¡G -l ¡G¤@¯ë¨Ó»¡¡A server »P client ¡yn¦³¬Û¦Pªº¨Ï¥ÎªÌ±b¸¹¦WºÙ¡z¤ñ¸û¦nªº¡I ¦pªG¨S¦³ªº¸Ü¡A¨º»ò±z¥²¶·n«ü©w server ªº¨Ï¥ÎªÌ±b¸¹¦W¤~¦æ¡I »·ºÝ¥D¾÷¦W ¡G±znµn¤Jªº¨º³¡ rsh.server ¥D¾÷¦WºÙ¡A°O±o»P /etc/hosts ¬ÛÀ³¡I »·ºÝ¥D¾÷«ü¥O¡G±zn¦b»·ºÝ¾÷¾¹¤W±¤U¹F¤°»ò«ü¥O¡H ½d¨Ò¤@¡G¦b rsh.server ¤W±¤U¹F ls -l / ³oÓ«ü¥O¡G [dmtsai@rshclient ~]$ rsh rsh.server 'ls -l /' .....¿é¥X¬Ù²¤..... # ª`·N³á¡A§Ú¬O¨Ï¥Î dmtsai ³oÓ¤@¯ë¨¥÷¨Ï¥ÎªÌ¡A¦Ó¥B rshserver rshclient # ¨â³¡¥D¾÷¤W±³£¦³¤@Ó¦W¬° dmtsai ªº¨Ï¥ÎªÌ±b¸¹¤~¦æ³á¡I¦Ü©ó¨ºÓ ls -l / # «h¬O¦b rsh.server ¥D¾÷¤W±ªº«ü¥O¡I¯d·N¯d·N¡I |
½d¨Ò¡G¥ý¬d¾\»·ºÝ¥D¾÷¦³¤°»ò¸ê®Æ¡AµM«á±N¥L½Æ»s¹L¨Ó¡G [dmtsai@rshclient ~]# rsh rsh.server 'ls -l ~' drwx------ 3 dmtsai dmtsai 4096 Dec 27 2005 Desktop -rw-r--r-- 1 dmtsai dmtsai 3385 May 29 17:52 bashrc drwx------ 3 dmtsai dmtsai 4096 Mar 6 2006 mail -rw-r--r-- 1 dmtsai dmtsai 883888 May 29 17:51 netcdf.tar.gz drwxr-xr-x 2 dmtsai dmtsai 4096 Jul 26 16:05 test -rw-rw-r-- 1 dmtsai dmtsai 34816 Mar 19 2006 testing.ppt [dmtsai@rshclient ~]# rcp -r dmtsai@rsh.server:~/mail . # ¥[¤W -r ¬O¬°¤Fn½Æ»s¥Ø¿ý³á¡I§_«hªº¸Ü¡A¥i¥Hª½±µ½Æ»s§Y¥i¡I |
[root@linux ~]# rsync [-avrlptgoD] [-e ssh] [user@host:/dir] [/local/path] °Ñ¼Æ¡G -v ¡GÆ[¹î¼Ò¦¡¡A¥i¥H¦C¥X§ó¦hªº¸ê°T¡F -q ¡G»P -v ¬Û¤Ï¡A¦wÀR¼Ò¦¡¡A¿é¥Xªº¸ê°T¤ñ¸û¤Ö¡F -r ¡G»¼°j½Æ»s¡I¥i¥H°w¹ï¡y¥Ø¿ý¡z¨Ó³B²z¡I«Ü«n¡I -u ¡G¶È§ó·s (update)¡A¤£·|Âл\¥Ø¼Ðªº·sÀɮסF -l ¡G½Æ»s³sµ²ÀɪºÄÝ©Ê¡A¦Ó«D³sµ²ªº¥Ø¼Ðì©lÀɮפº®e¡F -p ¡G½Æ»s®É¡A³s¦PÄÝ©Ê (permission) ¤]«O¦s¤£ÅÜ¡I -g ¡G«O¦sì©lÀɮתº¾Ö¦³¸s²Õ¡F -o ¡G«O¦sì©lÀɮתº¾Ö¦³¤H¡F -D ¡G«O¦sì©lÀɮתº¸Ë¸mÄÝ©Ê (device) -t ¡G«O¦sì©lÀɮתº®É¶¡°Ñ¼Æ¡F -I ¡G©¿²¤§ó·s®É¶¡ (mtime) ªºÄÝ©Ê¡AÀɮפñ¹ï¤W·|¤ñ¸û§Ö³t¡F -z ¡G¥[¤WÀ£ÁYªº°Ñ¼Æ¡I -e ¡G¨Ï¥Îªº³q¹D¨ó©w¡A¨Ò¦p¨Ï¥Î ssh ³q¹D¡A«h -e ssh -a ¡G¬Û·í©ó -rlptgoD ¡A©Ò¥H³oÓ -a ¬O³Ì±`¥Îªº°Ñ¼Æ¤F¡I §ó¦h»¡©ú½Ð°Ñ¦Ò man rsync ªº¸Ñ»¡¡I ½d¨Ò¤@¡G±N /etc ªº¸ê®Æ³Æ¥÷¨ì /tmp ©³¤U¡G [root@linux ~]# rsync -av /etc /tmp ....«e±¿é¥X¬Ù²¤.... sent 23007335 bytes received 32280 bytes 5119914.44 bytes/sec total size is 22870014 speedup is 0.99 # ²Ä¤@¦¸¹B§@®É·|ªá¤ñ¸û¤[ªº®É¶¡¡A¦]¬°º¦¸«Ø¥ß¹À¡I¦pªG¦A¦¸³Æ¥÷©O¡H [root@linux ~]# rsync -av /etc /tmp building file list ... done sent 77105 bytes received 20 bytes 154250.00 bytes/sec total size is 22870014 speedup is 296.53 # Á@¡I¥ß¨è´N¶]§¹¤F¡I¶Ç¿éªº¸ê®Æ¤]«Ü¤Ö¡I¦]¬°¦A¦¸¤ñ¹ï¡A¶È¦³®t²§ªºÀÉ®×·|³Q½Æ»s¡C ½d¨Ò¤G¡G§Q¥Î dmtsai ªº¨¥÷¡A±N rsh.server ¨Ï¥ÎªÌ®a¥Ø¿ý½Æ»s¨ì /tmp [root@linux ~]# rsync -av -e ssh dmtsai@rsh.server:~ /tmp The authenticity of host 'rsh.server (192.168.1.2)' can't be established. RSA key fingerprint is 29:b8:a9:32:ea:d8:ff:97:6c:42:3b:aa:11:ab:55:dd. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'rsh.server' (RSA) to the list of known hosts. dmtsai@rsh.server's password: receiving file list ... done ....Àɮ׿é¥X¬Ù²¤.... sent 8436 bytes received 43224862 bytes 2789245.03 bytes/sec total size is 43189031 speedup is 1.00 [root@linux ~]# ll -d /tmp/dmtsai drwxr-xr-x 22 dmtsai dmtsai 4096 Sep 18 23:25 /tmp/dmtsai # Á@¡I³o¼Ë´N°µ¦n³Æ¥÷°Õ¡I«Ü²³æ§a¡I |