Telnet
Telnet on yksinkertainen tietoliikenneohjelma. Jos tuntee tarvittavat protokollat, sitä voi käyttää esimerkiksi webbiselaimena sekä sähköposti- ja FTP-ohjelmana.
HTTP eli webbiselaus
Sivujen hakeminen WWW:stä on melko helppoa telnet-ohjelmalla. Yksinkertaisimmillaan seuraava esimerkki riittää
kosh ~ 92 % telnet www.hut.fi 80 Trying 130.233.220.31... Connected to www.hut.fi. Escape character is '^]'. GET / HTTP/1.0 HTTP/1.1 200 OK Date: Wed, 30 Oct 2002 12:27:05 GMT Server: Apache/1.3.26 (Unix) Last-Modified: Fri, 18 Oct 2002 14:20:11 GMT ETag: "1a31a-c88-3db0189b" Accept-Ranges: bytes Content-Length: 3208 Connection: close Content-Type: text/html; charset=ISO-8859-1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <title>Teknillinen korkeakoulu - TKK</title> ...
Jos www-palvelin on hieman nirsompi, se saattaa haluta, että sille kerrotaan myös palvelimen oikea nimi:
kosh ~ 104 % telnet www.hel.fi 80 Trying 137.163.136.2... Connected to www.hel.fi. Escape character is '^]'. GET / HTTP/1.0 Host: www.hel.fi HTTP/1.1 200 OK Server: Microsoft-IIS/4.0 Content-Location: http://www.hel.fi/index.html Date: Wed, 30 Oct 2002 12:47:09 GMT Content-Type: text/html Accept-Ranges: bytes Last-Modified: Wed, 30 Oct 2002 07:09:59 GMT ETag: "2e4ab95be37fc21:58e1" Content-Length: 22828 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <META NAME="DC.Title" CONTENT="Helsingin kaupunki"> <META NAME="Title" CONTENT="Helsingin kaupunki"> ...
Sähköpostin lähetys
Telnet-ohjelmalla on myös yksinkertaista lähettää sähköpostia SMTP-protokollaa käyttäen.
Esimerkki:
kosh ~ 159 % telnet smtp.hut.fi smtp Trying 130.233.228.91... Connected to smtp.hut.fi. Escape character is '^]'. 220 smtp-1.hut.fi ESMTP Sendmail; Thu, 22 Aug 2002 13:40:57 +0300 HELO kosh.hut.fi 250 smtp-1.hut.fi Hello kosh.hut.fi [130.233.228.10], pleased to meet you MAIL FROM: mikko.reinikainen@iki.fi 250 2.1.0 mikko.reinikainen@iki.fi... Sender ok RCPT TO: mire@iki.fi 250 2.1.5 mire@iki.fi... Recipient ok DATA 354 Enter mail, end with "." on a line by itself Subject: Testi Testiviesti - Mikko . 250 2.0.0 g7MAev1t029656 Message accepted for delivery quit 221 2.0.0 smtp-1.hut.fi closing connection Connection closed by foreign host. kosh ~ 160 %
FTP-yhteys
Aktiivinen FTP
Aktiivinen tiedostonsiirto FTP:llä tarkoitetaan, että paikallisen koneen jokin portti varataan datayhteydelle. Tällöin FTP-palvelin ottaa aktiivisesti itse yhteyden asiakkaaseen.
Seuraavassa esimerkissä laitetaan ensin netcat-ohjelma odottamaan yhteyttä paikallisen koneen porttiin 12345. Netcat tulostaa kaiken, mitä porttiin kirjoitetaan. Sitten otetaan telnetillä yhteys palvelimeen, annetaan käyttäjätunnus "anonymous" ja salasanaksi oma sähköpostiosoite. Komennolla CWD siirrytään haluttuun hakemistoon. Komennolla PORT asetetaan datayhteyden tiedot, eli paikallinen kone ja paikallisen koneen portti. Ensimmäiset neljä numeroa ovat koneen ip-numero, viimeiset kaksi haluttu portti (48*256+57 = 12345). Komennolla LIST haetaan tiedostolistaus, jonka netcat-ohjelma tulostaa näkyville. Komennolla QUIT suljetaan ftp-yhteys.
kosh ~ 52 % telnet ftp.funet.fi ftp Trying 193.166.3.2... Connected to ftp.funet.fi. Escape character is '^]'. 220-Hello UNKNOWN at kosh.hut.fi, 220- 220-Welcome to the FUNET archive, Please login as `anonymous' with 220-your E-mail address as the password to access the archive. 220-See the README file for more information about this archive. 220- 220- All anonymous transfers are logged with your host name and whatever you 220- entered for the password. If you don't like this policy, disconnect now! 220- 220-THIS is a four processor SUN 450/4GB/600+GB system 220-Please mail to problems@nic.funet.fi in case of problems 220- 220- 220-ftp.funet.fi FTP server (Version 4.1487 problems@ftp.funet.fi) ready. 220-There are 78 (max 250) archive users in your class at the moment. 220-Assuming 'login anonymous', other userids do vary.) 220-Local time is Wed Oct 30 13:13:09 2002 EET 220- 220 You can do "get README" even without logging in! USER anonymous 331 Guest login ok, give your E-mail address for password. PASS mtreinik@cc.hut.fi 230-Guest `mtreinik@cc.hut.fi' login ok. 230- 230- Finnish University and Research network FUNET 230- Archive FTP.FUNET.FI 230- 230-Most important file name suffixes are described at /README.FILETYPES 230- 230-Welcome, you are 80th archive user in your class (max 250). 230-Your class is named: Finnish/Baltic/Russian 230-There are 349 users in all classes (max 687) 230-Your data-transfer rate has no limitations. 230- 230-Local time is Wed Oct 30 13:13:16 2002 EET 230- 230-We have special access features, see file README 230- It was last updated Thu Oct 11 19:48:59 2001 - 383.8 days ago 230 CWD pub 250 CWD command successful. PORT 130,233,228,10,48,57 200 PORT command successful. LIST 150 Opening ASCII mode data connection for . drwxrwxr-x 12 jhi cpan-adm 8192 Oct 30 10:23 CPAN drwxrwxr-x 3 mirror mirror 96 Jun 4 13:17 FreeBSD drwxrwxr-x 17 hks maints 8192 Aug 28 11:06 Linux drwxrwsr-x 24 hks maints 8192 Jan 11 2000 NeXT drwxr-xr-x 16 mirror mirror 8192 Sep 18 04:04 NetBSD drwxrwxr-x 21 hks maints 8192 Oct 17 1999 OS -rw-r--r-- 1 root csc 28263 Nov 12 1997 README drwxr-xr-x 18 hks maints 8192 Jan 11 2000 TeX drwxrwxr-x 10 hks maints 8192 Jan 11 2000 X11 drwxrwxr-x 22 hks maints 8192 Mar 26 2000 amiga drwxrwxr-x 63 hsu maints 8192 Dec 30 1999 archive drwxrwxr-x 8 hks maints 8192 Apr 20 2000 astro drwxrwsr-x 39 hks maints 8192 Jul 20 2000 atari drwxrwxr-x 12 hks maints 8192 Oct 26 1999 cae drwxrwxr-x 25 hks maints 8192 Oct 29 23:45 cbm drwxrwxr-x 12 hks maints 8192 Oct 29 23:47 cpm drwxrwxr-x 15 hks maints 8192 Jun 14 2000 crypt drwxrwxr-x 15 root csc 8192 Apr 16 2002 csc drwxrwxr-x 18 hks maints 8192 Jan 11 2000 culture drwxrwxr-x 53 hks maints 8192 Jan 11 2000 doc drwxr-xr-x 9 hks maints 8192 Jan 11 2000 dx drwxr-xr-x 62 metadb metadb 8192 Mar 11 2002 files drwxrwxr-x 4 hks maints 8192 Dec 4 2000 gnu drwx226 Transfer complete. rwxr-x 7 hks maints 8192 Aug 21 19:29 graphics drwxrwxr-x 33 hks maints 8192 Aug 28 05:18 ham drwxr-xr-x 42 mirror mirror 8192 Oct 10 01:09 kermit drwxrwxr-x 47 hks languages-adm 8192 Jan 11 2000 languages -rw-r--r-- 1 hks guru 2314769 Nov 16 1999 levyn.du drwxrwxr-x 17 hks maints 8192 Aug 28 11:06 linux drwxr-sr-x 4 hks maints 8192 Aug 11 1999 local drwxr-xr-x 3 hks maints 96 Aug 11 1999 lyhty drwxr-xr-x 50 hks maints 8192 Jan 11 2000 mac drwxr-xr-x 17 hks maints 8192 Oct 17 1999 mach drwxrwxr-x 30 hks maints 8192 Jan 11 2000 microprocs drwxr-xr-x 19 hks maints 8192 Jan 11 2000 minix drwxr-xr-x 25 hks guru 8192 Oct 21 08:00 mirrors drwxr-xr-x 23 hks maints 8192 Jan 11 2000 misc drwxrwxr-x 27 hks maints 8192 Aug 17 13:47 msdos drwxrwxr-x 19 hks maints 8192 Oct 1 09:00 msx drwxrwsr-x 29 hks maints 8192 Jan 11 2000 netinfo drwxrwsr-x 16 hks maints 8192 Jan 11 2000 networking drwxrwxr-t 9 hks maints 8192 Mar 24 2002 org drwxrwxr-x 10 hks maints 8192 Jan 11 2000 os2 drwxrwxr-x 27 hks maints 8192 Jan 11 2000 pics drwxrwsr-x 4 hks maints 8192 Oct 17 1999 projects drwxrwxr-x 28 hks maints 8192 May 23 20:31 sci drwxrwxr-x 7 hks sounds-adm 8192 Jan 11 2000 sounds drwxr-xr-x 18 hks maints 8192 Oct 17 1999 sports drwxrwxr-x 6 hks maints 8192 Oct 17 1999 standards drwxrwsr-x 47 hks maints 8192 Aug 20 12:32 unix drwxrwxr-x 13 hks maints 8192 Jan 11 2000 vms drwxrwxr-x 18 hks maints 8192 Oct 17 1999 win-nt drwxrwxr-x 3 bande maints 96 Aug 17 13:48 win32 drwxrwxr-x 5 hks maints 8192 Jun 5 2000 windows QUIT 221-Goodbye, and thank you for using the FUNET archive. 221 You transferred 3 KBytes during this session. Connection closed by foreign host. [1] + Done nc -l -p 12345 kosh ~ 53 %
Passiivinen FTP
Passiivisessa tiedonsiirrossa otetaan erikseen datayhteys esimerkiksi telnet-ohjelmalla ftp-palvelimeen.
kosh ~ 90 % telnet ftp.funet.fi ftp Trying 193.166.3.2... Connected to ftp.funet.fi. Escape character is '^]'. 220-Hello UNKNOWN at kosh.hut.fi, 220- 220-Welcome to the FUNET archive, Please login as nonymous' with 220-your E-mail address as the password to access the archive. 220-See the README file for more information about this archive. 220- 220- All anonymous transfers are logged with your host name and whatever you 220- entered for the password. If you don't like this policy, disconnect now! 220- 220-THIS is a four processor SUN 450/4GB/600+GB system 220-Please mail to problems@nic.funet.fi in case of problems 220- 220- 220-ftp.funet.fi FTP server (Version 4.1487 problems@ftp.funet.fi) ready. 220-There are 82 (max 250) archive users in your class at the moment. 220-Assuming 'login anonymous', other userids do vary.) 220-Local time is Wed Oct 30 13:18:02 2002 EET 220- 220 You can do "get README" even without logging in! USER anonymous 331 Guest login ok, give your E-mail address for password. PASS mikko.reinikainen@iki.fi 230-Guest ikko.reinikainen@iki.fi' login ok. 230- 230- Finnish University and Research network FUNET 230- Archive FTP.FUNET.FI 230- 230-Most important file name suffixes are described at /README.FILETYPES 230- 230-Welcome, you are 82th archive user in your class (max 250). 230-Your class is named: Finnish/Baltic/Russian 230-There are 359 users in all classes (max 687) 230-Your data-transfer rate has no limitations. 230- 230-Local time is Wed Oct 30 13:18:33 2002 EET 230- 230-We have special access features, see file README 230- It was last updated Thu Oct 11 19:48:59 2001 - 383.8 days ago 230 CWD pub 250 CWD command successful. PASV 227 Entering Passive Mode (193,166,3,2,244,206)
Tämän jälkeen käynnistetään datayhteys ftp-palvelimeen. Edellisen komennon vastauksessa on suluissa kuusi numeroa. Neljä ensimmäistä kertoo ip-osoitteen ja kaksi viimeistä portin johon tulee otta yhteys. Portin numero lasketaan kaavalla x * 256 + y, missä x ja y ovat kaksi viimeistä suluissa olevaa numeroa.
kosh ~ 51 % telnet 193.166.3.2 62670 Trying 193.166.3.2... Connected to 193.166.3.2. Escape character is '^]'.
Nyt voidaan antaa toisessa telnet-istunnossa komento, joka listaa hakemiston sisällön.
LIST 150 Opening ASCII mode data connection for . 226 Transfer complete.
Listauskomennon antamisen jälkeen toiseen telnet-istuntoon tulostuu tiedostolistaus.
drwxrwxr-x 12 jhi cpan-adm 8192 Oct 30 10:23 CPAN drwxrwxr-x 3 mirror mirror 96 Jun 4 13:17 FreeBSD drwxrwxr-x 17 hks maints 8192 Aug 28 11:06 Linux drwxrwsr-x 24 hks maints 8192 Jan 11 2000 NeXT drwxr-xr-x 16 mirror mirror 8192 Sep 18 04:04 NetBSD drwxrwxr-x 21 hks maints 8192 Oct 17 1999 OS -rw-r--r-- 1 root csc 28263 Nov 12 1997 README ...
Tämän jälkeen ftp-yhteyden voi sulkea.
QUIT 221-Goodbye, and thank you for using the FUNET archive. 221 You transferred 3 KBytes during this session. Connection closed by foreign host. kosh ~ 91 %
Lisätietoja