bab iv transfer data -...
TRANSCRIPT
BAB IVTRANSFER DATA
TUJUAN PRAKTIKUMSetelah melaksanakan praktikum, peserta diharapkan mampu:1. Memahami tentang SSH server2. Melakukan konfigurasi SSH server3. Melakukan konfigurasi SSH client4. Memahami cara kerja FTP5. Mengkonfigurasi FP server6. Mengakses melalui FTP client.
DASAR TEORISSH
SSH server merupakan suatu program aplikasi yang berfungsi untuk melakukan remote server untuk suatu keperluan, antara lain untuk melakukan pemeliharaan sistem dan administrasi user maupun grup serta untuk melakukan pengamatan dan pengawasan mesin dari jauh.
Dalam praktikum ini, kita menggunakan OpenSSH karena terbukti OpenSSH merupakan proyek GNU yang terjamin keamanannya dan bersifat gratis. Dikatakan aman, karena jika kita menggunakan program telnet untuk mengakses server dari jauh akan mengakibatkan data/perintah yang kita kirim bisa dilacak atau dibaca oleh orang lain. Sedangkan jika kita menggunakan OpenSSH, semua paket data yang akan dikirim oleh mesin, akan terlebih dahulu diacak (dienkripsi) sehingga paket data akan terkirim secara biner. Setelah tiba di server, paket data akan diuraikan kembali sehingga bisa terbaca oleh sistem.
FTPFTP (File Transfer Protocol) adalah protokol yang digunakan untuk transfer file
antara dua host yang terdapat dalam jaringan. FTP adalah nama dari program client yang akan menghubungi ftpd, yaitu FTP daemon yang berfungsi sebagai server yang melayani permintaan client. Ketika client menghubungi ftpd, maka ftpd akan membuat jalur koneksi melalui port 21 sehingga user bisa mengirimkan perintahnya melalui port ini. Namun demikian transfer file dilakukan melalui port 20.
Di dalam pemakaian FTP, dikenal dua macam hak akses bagi pemakai, yaitu:Anonymous FTP, setiap pemakai dapat menggunakan FTP untuk mengakses
sebuah host tanpa harus mempunyai account di dalam host tersebut. Pemakaian anonymous FTP dengan memasukkan login dengan nama user anonymous dan passwordnya dapat berupa alamat mail atau guest atau tanpa password (tergantung dari host yang dituju).
Hanya user tertentu saja yang menggunakan FTP, yaitu dengan cara login dengan nama user dan password yang sudah didaftarkan sebelumnya.
Jenisjenis file pada FTP site:2. File text, filefile ini merupakan file yang berbentuk text dengan ekstensi .txt.
File ini dapat dibuka melalui text editor.
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
3
3. File binary, yang termasuk jenis ini adalah file program, gambar, suara, termasuk file terkompresi seperti .zip, .tar, .gz, dll.
LANGKAH PRAKTIKUM
1. SSH
Konfigurasi SSH Server.
1. Pastikan paket openssh sudah terinstal pada saat installasi Linux.
user@himatif:~$ sudo dpkg -l | grep sshii openssh-client 4.2p1-7ubuntu3 Secure shell client, an rlogin/rsh/rcp replaii ssh-askpass-gnome 4.2p1-7ubuntu3 under X, asks user for a passphrase for ssh-
2. Lakukan editing pada file /etc/ssh/sshd_config, dengan cara ketikkan
perintah berikut ini:
user@himatif:~$ sudo vi /etc/ssh/sshd_config
3. Perintah tersebut diatas akan menampilkan isi dari file /etc/ssh/sshd_config, seperti berikut ini:
user@himatif:~$ sudo vi /etc/ssh/sshd_config# Package generated configuration file# See the sshd(8) manpage for details
# What ports, IPs and protocols we listen forPort 22# Use these options to restrict which interfaces/protocols sshd will bind to#ListenAddress ::#ListenAddress 0.0.0.0Protocol 2# HostKeys for protocol version 2HostKey /etc/ssh/ssh_host_rsa_keyHostKey /etc/ssh/ssh_host_dsa_key#Privilege Separation is turned on for securityUsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server keyKeyRegenerationInterval 3600ServerKeyBits 768
# LoggingSyslogFacility AUTHLogLevel INFO
# Authentication:LoginGraceTime 120PermitRootLogin yesStrictModes yes
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
3
RSAAuthentication yesPubkeyAuthentication yes#AuthorizedKeysFile %h/.ssh/authorized_keys
# Don't read the user's ~/.rhosts and ~/.shosts filesIgnoreRhosts yes# For this to work you will also need host keys in /etc/ssh_known_hostsRhostsRSAAuthentication no# similar for protocol version 2HostbasedAuthentication no# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication#IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with# some PAM modules and threads)ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords#PasswordAuthentication yes
# Kerberos options#KerberosAuthentication no#KerberosGetAFSToken no#KerberosOrLocalPasswd yes#KerberosTicketCleanup yes
# GSSAPI options#GSSAPIAuthentication no#GSSAPICleanupCredentials yes
X11Forwarding yesX11DisplayOffset 10PrintMotd noPrintLastLog yesKeepAlive yes#UseLogin no
#MaxStartups 10:30:60#Banner /etc/issue.net
# Allow client to pass locale environment variablesAcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
4. Pada kalimat port 22, hilangkan tanda pagar (#).5. Jika anda menghendaki bisa melakukan remote server sebagai root, hilangkan
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
3
tanda pagar (#) pada kalimat #PermitRootLogin yes.6. Jika anda menghendaki penggunaan autentikasi menggunakan metode RSA
(Standard Keamanan Amerika), anda bisa menghilangkan tanda pagar (#) pada kalimat #RSAAuthentication yes
7. Jika sudah selesai, simpan hasil pekerjaan anda.8. Untuk menjalankan openssh server, ketikkan perintah berikut ini:
user@himatif:~$ sudo /etc/init.d/ssh start
9. Untuk menjalankan secara otomatis pada saat komputer dinyalakan, ketikkan perintah berikut ini:
user@himatif:~$ cd /etc/init.d/root@himatif:/etc/init.d# updaterc.d n ssh defaults
Konfigurasi SSH Client.Pada sisi client, anda tidak perlu melakukan konfigurasi, anda hanya tinggan
menggunakannya saja. Untuk menggunakan openssh pada komputer anda, pastikan paket openssh sudah terinstall pada sistem anda.
Menggunakan Perintah OpenSSH1. Pada konsol, login sebagai user nama_user:
Login: nama_userPassword: <password_user>
2. Pada konsol, ketikkan perintah sebagai berikut:
[nama_user@himatif ~]$ ssh 192.168.123.1
3. Jika anda belum pernah melakukan koneksi ke server dengan user, anda akan mendapat pertanyaan seperti berikut ini:
The authenticity of host '192.168.123.1 (192.168.123.1)' can't be established.RSA key fingerprint is 08:b4:86:52:e6:0b:36:9c:53:f2:1f:c1:90:90:21:53.Are you sure you want to continue connecting (yes/no)?
4. Jawablah dengan mengetikkan y (yes), selanjutnya fingerprint anda ke server akan disimpan oleh sistem.
Warning: Permanently added '192.168.123.1' (RSA) to the list of known hosts.
5. Jika pada server terdapat user user, anda akan langsung ditanyakan password anda, seperti berikut ini:
[email protected] 's password:
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
3
6. Isikan password user, selanjutnya anda bisa mengoperasikan server seperti layaknya anda mengoperasikan PC anda sendiri sebagai user user. Tampilannya adalah sebagai berikut:
[nama_user@serverssh ~]$
Mengoperasikan SSH Tanpa LoginUntuk melakukan ssh ke server tanpa melalui login langkahnya adalah sebagai
berikut:• Pada konsol, login sebagai user user:
Login: nama_userPassword: <password_user>
• Jika anda ingin mengetahui isi direktori pada server, ketikkan perintah berikut ini:
[nama_user@himatif ~]$ ssh <IP server> perintah
[nama_user@himatif ~]$ ssh 192.168.123.1 ls /home/
• Selanjutnya, akan tampil permintaan pengisian password, isikan password yang dikehendaki:
[email protected] 's password: <isikan_passwd_user>
• Jika password anda disetujui, akan keluar tampilan seperti berikut ini:
[user@himatif ~]$ ssh 192.168.123.1 ls /home/[email protected] 's password:Adobe Photoshop 7.0 INBOX.Trashbab I tcpip.sxw ksl.jpgbab iv DNS.sxw linux1.psdbab iv web server.sxw Login.docBab VII mail server.sxw login php.sxibus mboxbus.png modul praktikum jaringan.sxwdaftar login.sxw modul sistem operasi (bab I).sxwDesktop problem.txtdiburn ring.png
Mengirim File Dengan SCPScp merupakan perintah pengiriman file/data pada openssh secara terenskripsi,
sehingga data/file yang terkirim lebih aman. Adapun caranya adalah sebagai berikut:1. Pada konsol, loginlah sebagai user user:
Login: userPassword: <password_user>
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
3
2. Jika anda ingin mengirim file ke server, pada home direktori student, ketikkan perintah berikut ini:
[student@himatif ~]$ scp file [email protected] :/home/
3. Selanjutnya akan muncul tampilan seperti berikut ini:
[email protected] 's password:
4. Jika password anda disetujui, file akan dikirim dengan terenskripsi.
file 100% 40KB 1.3MB/s 00:00
1. FTP
Konfigurasi vsftpd1. Pastikan paket FTP sudah terinstal pada saat installasi Linux:
user@himatif:~$ sudo dpkg -l | grep ftpii ftp 0.17-16 The FTP clientii lftp 3.4.0-1 Sophisticated command-line FTP/HTTP client pii vsftpd 2.0.4-0ubuntu4 The Very Secure FTP Daemon
2. Jika belum terinstall lakukan installasi source deb dari cd dengan perintah:
user@himatif:~$ dpkg -i nama_paket.deb
Atauuser@himatif:~$ aptget install nama_paket.deb
3. File yang harus dikonfigurasi untuk menjalankan vsftpd adalah /etc/vsftpd/vsftpd.conf. Berikut contoh konfigurasi /etc/vsftpd/vsftpd.conf:
user@himatif:~$ vi /etc/vsftpd.conf
# Example config file /etc/vsftpd.conf## The default compiled in settings are fairly paranoid. This sample file# loosens things up a bit, to make the ftp daemon more usable.# Please see vsftpd.conf.5 for all compiled in defaults.## READ THIS: This example file is NOT an exhaustive list of vsftpd options.# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's# capabilities.
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
3
### Run standalone? vsftpd can run either from an inetd or as a standalone# daemon started from an initscript.listen=YES## Run standalone with IPv6?# Like the listen parameter, except vsftpd will listen on an IPv6 socket# instead of an IPv4 one. This parameter and the listen parameter are mutually# exclusive.#listen_ipv6=YES## Allow anonymous FTP? (Beware - allowed by default if you comment this out).anonymous_enable=YES## Uncomment this to allow local users to log in.#local_enable=YES## Uncomment this to enable any form of FTP write command.#write_enable=YES## Default umask for local users is 077. You may wish to change this to 022,# if your users expect that (022 is used by most other ftpd's)#local_umask=022## Uncomment this to allow the anonymous FTP user to upload files. This only# has an effect if the above global write enable is activated. Also, you will# obviously need to create a directory writable by the FTP user.#anon_upload_enable=YES## Uncomment this if you want the anonymous FTP user to be able to create# new directories.#anon_mkdir_write_enable=YES## Activate directory messages - messages given to remote users when they# go into a certain directory.dirmessage_enable=YES## Activate logging of uploads/downloads.xferlog_enable=YES## Make sure PORT transfer connections originate from port 20 (ftp-data).connect_from_port_20=YES## If you want, you can arrange for uploaded anonymous files to be owned by
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
3
# a different user. Note! Using "root" for uploaded files is not# recommended!#chown_uploads=YES#chown_username=whoever## You may override where the log file goes if you like. The default is shown# below.#xferlog_file=/var/log/vsftpd.log## If you want, you can have your log file in standard ftpd xferlog format#xferlog_std_format=YES## You may change the default value for timing out an idle session.#idle_session_timeout=600## You may change the default value for timing out a data connection.#data_connection_timeout=120## It is recommended that you define on your system a unique user which the# ftp server can use as a totally isolated and unprivileged user.#nopriv_user=ftpsecure## Enable this and the server will recognise asynchronous ABOR requests. Not# recommended for security (the code is non-trivial). Not enabling it,# however, may confuse older FTP clients.#async_abor_enable=YES## By default the server will pretend to allow ASCII mode but in fact ignore# the request. Turn on the below options to have the server actually do ASCII# mangling on files when in ASCII mode.# Beware that on some FTP servers, ASCII support allows a denial of service# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd# predicted this attack and has always been safe, reporting the size of the# raw file.# ASCII mangling is a horrible feature of the protocol.#ascii_upload_enable=YES#ascii_download_enable=YES## You may fully customise the login banner string:#ftpd_banner=Welcome to blah FTP service.## You may specify a file of disallowed anonymous e-mail addresses. Apparently
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
3
# useful for combatting certain DoS attacks.#deny_email_enable=YES# (default follows)#banned_email_file=/etc/vsftpd.banned_emails## You may restrict local users to their home directories. See the FAQ for# the possible risks in this before using chroot_local_user or# chroot_list_enable below.#chroot_local_user=YES## You may specify an explicit list of local users to chroot() to their home# directory. If chroot_local_user is YES, then this list becomes a list of# users to NOT chroot().#chroot_list_enable=YES# (default follows)#chroot_list_file=/etc/vsftpd.chroot_list## You may activate the "-R" option to the builtin ls. This is disabled by# default to avoid remote users being able to cause excessive I/O on large# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume# the presence of the "-R" option, so there is a strong case for enabling it.#ls_recurse_enable=YES### Debian customization## Some of vsftpd's settings don't fit the Debian filesystem layout by# default. These settings are more Debian-friendly.## This option should be the name of a directory which is empty. Also, the# directory should not be writable by the ftp user. This directory is used# as a secure chroot() jail at times vsftpd does not require filesystem# access.secure_chroot_dir=/var/run/vsftpd## This string is the name of the PAM service vsftpd will use.pam_service_name=vsftpd## This option specifies the location of the RSA certificate to use for SSL# encrypted connections.rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem## This option specifies the location of the RSA key to use for SSL# encrypted connections.
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
3
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
4. Pengaksesan FTP server dengan user yang sudah terdaftar akan ditempatkan langsung secara default ke masingmasing user home direktori.
5. Menjalankan dan menghentikan service vsftpd, untuk menjalankannya digunakan perintah berikut:
user@himatif:~$ /etc/init.d/vsftpd start
6. Jika dilakukan perubahan konfigurasi, maka service harus direstart untuk memberi instruksi agar service membaca ulang konfigurasi yang telah diubah denga perintah sebagai berikut:
user@himatif:~$ /etc/init.d/vsftpd restart
7. Sedangkan untuk menghentikannya secara penuh dengan perintah berikut:
user@himatif:~$ /etc/init.d/vsftpd stop
Menggunakan FTP ServerUntuk melakukan transfer file, sebelumnya client harus melakukan koneksi
dengan server FTP. Pemanggilan FTP client dapat dilakukan dengan perintah:
# ftp <target_IP_atau_host>
[student@himatif student]$ ftp 192.168.231.1
Connected to 192.168.231.1 (192.168.231.1).220 (vsFTPd 1.2.0)Name (192.168.231.1:himatif): aan
331 Please specify the password.Password:
230 Login successful.Remote system type is UNIX.
Using binary mode to transfer files.ftp>
Masukkan nama user dan passwordnya untuk login. Jika login berhasil, akan muncul prompt FTP.
Untuk mengetahui perintah apa saja yang digunakan, ketikkan perintah ?.
ftp> ?
Format file yang akan ditransfer bisa dalam bentuk format text maupun binary. Tetapi bila file yang ditransfer adalah binary maka harus ditransfer dalam format binary (jika tidak, mungkin file yang ditransfer akan rusak). Secara default format
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
4
transfer file adalah text. Sedangkan untuk melakukan transfer file dalam format binary, harus diberikan perintah binary. Dan untuk transfer file dalam bentuk text, ketikkan perintah ascii.
ftp> binary200 Switching to Binary mode.ftp> ascii200 Switching to ASCII mode.ftp>
Untuk melihat isi remote host (FTP server), dapat digunakan perintah berikut:
ftp> ls
Dan untuk melihat isi current direktori host lokal digunakan perintah:
ftp> !ls
Untuk mendownload sebuah file dari FTP server digunakan perintah:
ftp> get nama_file
Dan untuk mendownload banyak file:
ftp> mget *
Untuk mengirim file ke FTP server digunakan perintah:
ftp> send nama_file
atau
ftp> put nama_fileDan untuk mengirim banyak file
ftp> mput *
Untuk keluar dari prompt FTP dan memutuskan koneksi dengan FTP server digunakan perintah
ftp> exit
atau
ftp> quit
atau
ftp> bye
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
4
Berikut akan disampaikan sedikit lagi tentang perintahperintah yang ada dalam FTP.
Perintah Keteranganopen koneksi ke FTP serverclose/disconnect menutup FTP sessionquit menutup FTP session dan keluaruser kirim username yang barubin/binary set tipe transfer file ke binaryasc/ascii set tipe transfer file ke asciiget/mget download file tunggal atau multi fileput/mput upload file tunggal atau multi filehash menampilkan atau menyembunyikan progress barprompt mematikan atau menghidupkan prompt pertanyaan untuk multi filels melihat daftar file/direktori pada FP serverdelete/mdelete menghapus file tunggal atau multi filecd pindah direktori pada FTP servermkdir membuat direktori pada FTP server
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
4
LEMBAR KERJA
1. Bagaimana cara untuk membatasi waktu idle login pada FTP (misal 5 menit)!............................................................................................................................
2. Bagaimana cara membatasi jumlah user yang dapat login ke FTP server pada waktu yang bersamaan?...........................................................................................................................
3. Bagaimana cara membuat dan menampilkan pesan/ banner pada waktu login ke SSH server?...........................................................................................................................
4. Bagaimana cara login ke SSH server menggunakan user login yang berbeda?...........................................................................................................................
5. Bagaimana cara mengirimkan (upload) suatu file local ke dalam suatu directory tertentu pada host yang berlainan menggunakan SCP?..........................................................................................................................
6. Bagaimana cara mendownload suatu file yang terletak pada suatu directory tertentu yang berlainan host menggunakan SCP?......................................................................................................................................................................................................................................................
Modul Praktikum OpenSourceD3 Ilmu Komputer UNS
4