Copy dengan SSH

26 Aug

I. Tujuan
Sebagai acuan teori untuk prosedur scp – secure copy atau remote file copy program atau copy dengan SSH, yang merupakan alternative copy selain FTP.

II. Cara Pengerjaan
1. format scp
scp [-pqrvBC46] [-F ssh_config] [-S program] [-P port] [-c cipher]
[-i identity_file] [-o ssh_option] [[user@]host1:]file1 […]
[[user@]host2:]file2

2. perintah scp secara langsung seperti di bawah ini
scp gv140905.dmp 172.20.141.1:/u01/app/oracle/product/10.1.0/db_1/dmp
Could not create directory ‘/home/oracle/.ssh’.
The authenticity of host ‘172.20.141.1 (172.20.141.1)’ can’t be established.
RSA key fingerprint is b2:92:5c:ec:83:38:0b:bd:ee:17:e5:2e:90:83:96:5b.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/oracle/.ssh/known_hosts).
oracle@172.20.141.1’s password:
gv140905.dmp 100% |*****************************| 901 MB 08:18

3. contoh diatas akan sulit diterapkan pada sebuah script, karena harus terlebih dulu memasukan password. Agar SSH atau SCP tidak menanyakan password maka baik sisi client maupun sisi server harus diset.

Configuration: Client Side
4. Generate SSH encryption key pair untuk filecopy account.
ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P ”
Generating public/private dsa key pair.
/home/oracle/.ssh/id_dsa already exists.
Overwrite (y/n)? y
Your identification has been saved in /home/oracle/.ssh/id_dsa.
Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
f3:f2:02:cf:a2:38:56:3b:51:55:5d:dc:ad:44:84:cb oracle@ptubsor2

5. keterangan ssh-keygen -t dsa
identification disimpan di /home/oracle/.ssh/id_dsa.
public key disimpan di /home/oracle/.ssh/id_dsa.pub.
key fingerprint adalah : f3:f2:02:cf:a2:38:56:3b:51:55:5d:dc:ad:44:84:cb oracle@ptubsor2
6. keyfiles disimpan di .ssh subdirectory dari home directory.
cd /home/oracle/.ssh
ls -la
total 8
drwxr-xr-x 2 oracle oinstall 4096 Sep 15 11:39 .
drwx—— 8 oracle oinstall 4096 Sep 15 11:37 ..
-rw——- 1 oracle oinstall 0 Sep 15 11:39 id_dsa
-rw-r–r– 1 oracle oinstall 0 Sep 15 11:39 id_dsa.pub

7. Copy public key komputer tujuan yang akan dicopy.
scp /home/oracle/.ssh/id_dsa.pub oracle@172.20.140.31:public-key.tmp
oracle@172.20.140.31:public-key.tmp
The authenticity of host ‘172.20.140.31 (172.20.140.31)’ can’t be established.
RSA key fingerprint is c1:a8:05:92:d0:b0:75:0d:90:46:3a:b7:d9:33:98:82.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘172.20.140.31’ (RSA) to the list of known hosts.
Enter passphrase for key ‘/home/oracle/.ssh/id_dsa’:
Enter passphrase for key ‘/home/oracle/.ssh/id_dsa’:
oracle@172.20.140.31’s password:
id_dsa.pub 100% |*****************************| 0 00:00

Configuration – Server Side

8. Login server tujuan sebagai user. Create .ssh subdirectory pada home directory
pwd
/home/oracle
mkdir .ssh
chmod 700 .ssh
cd .ssh

9. Tambahkan public-key.tmp ke akhir file authorized_keys
cat ~/public-key.tmp >> authorized_keys
chmod 700 /home/oracle/.ssh
rm ~/public-key.tmp

/home/oracle/backup/pindah
test scp tanpa login

10. Lakukan test dari client / tempat asal file ke server / tujuan copy
scp /home/oracle/initptubsor2.ora oracle@172.20.140.31:/home/oracle/contohinit.ora
initptubsor2.ora 100% |*****************************| 1348 00:00

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: