Professional Documents
Culture Documents
Lab 10 - Sử Dụng Công Cụ Putty, SecureCRT, Đăng Nhập SSH Server Từ Xa
Lab 10 - Sử Dụng Công Cụ Putty, SecureCRT, Đăng Nhập SSH Server Từ Xa
2.1.1 Cách 1: Sử dụng chương trình PSCP và PLINK để sao chép và thiết lập khóa
Trên Windows, mở cửa sổ lệnh, chuyển vào thư mục hiện hành:
cd C:\putty x64
Thực hiện các lệnh sau. CHÚ Ý: Thay XYZ bằng tài khoản NSD, password: 123456
C:\putty x64>dir
Volume in drive C has no label.
Volume Serial Number is 664D-51A0
Directory of C:\ putty x64
10/23/2018 02:33 PM <DIR> .
10/23/2018 02:33 PM <DIR> ..
07/04/2017 08:34 PM 313.912 PAGEANT.EXE
07/04/2017 08:34 PM 617.048 PLINK.EXE
10/23/2018 02:33 PM 1.482 pri.ppk
07/04/2017 08:34 PM 626.744 PSCP.EXE
07/04/2017 08:34 PM 643.144 PSFTP.EXE
10/23/2018 02:32 PM 477 XYZpub
07/04/2017 08:36 PM 283.045 PUTTY.CHM
07/04/2017 08:36 PM 33.608 PUTTY.CNT
07/04/2017 08:34 PM 854.072 PUTTY.EXE
07/04/2017 08:36 PM 699.745 PUTTY.HLP
07/04/2017 08:35 PM 407.104 PUTTYGEN.EXE
11 File(s) 4.480.381 bytes
2 Dir(s) 6.013.984.768 bytes free
// Tải khóa public lên Server bằng cách sử dụng chương trình PSCP.EXE
C:\putty x64> PSCP.EXE -pw 123456 XYZpub userID@192.168.0.10:XYZpub
C:\putty x64> plink -ssh userID @192.168.0.10 -pw 123456 cat
$HOME/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEApHFSmJuUYsuY0cNGMikwNNsw0Q50MT0RNKMtLk+/
RTCDCWWSfG8du37Id+trFNOJexvs4CK7AQOsEJW2vjoy5RuqALztQLPpmZZ7OB6Whb63OToU7EA+XMME0Ud
cd9ifCnHpyj7/l+x6dboDoniiY+4TZRwUiXMOwuN9xurXEcFMZzBjYQderFkdwakpz2t2qBiG4lIchztt/
JygzhT08K7QF6bp7yPHiXi9OpBRqQpmkiQ7gZugbAaz3cKqCUexph/cL+2CsL/
zN3WRJeDfLYJEbo5e0iCsxQ3g48C2vGzxOKSKNM1oWXqpb9XpDH/iAXM2C2k4qdeApYuJE9zFKQ==
C:\putty x32>
Chạy chương trình putty.exe để đăng nhập từ xa đến máy 192.168.0.10 sử dụng cặp
khóa pub/pri.ppk vừa tạo:
Chạy chương trình putty.exe để đăng nhập từ xa vào máy 192.168.0.10 với tài khoản NSD.
Sau khi đăng nhập vào Linux, thực hiện các lệnh sau:
USERID@VMKali:~$ ls -lF
total 48
-rw-r--r-- 1 XXX cntt 477 Oct 23 15:06 XYZpub
Chạy chương trình putty.exe để đăng nhập từ xa đến máy 192.168.0.10 sử dụng cặp
khóa công khai/khóa bí mật vừa tạo:
C:\putty x64> putty.exe
Click “Finish” When asked whether or not you want to upload the following key, say
NO!
Login to Linux Server (192.168.0.10) as fllow:
// scp file.txt remote_username@10.10.0.2:/remote/directory
Login to Linux server (IP addr: 192.168.0.10) with your username and password and cat
the content of the public key:
user01@VMKali:~$ ls -lF
total 56
-rw-r--r-- 1 user01 root 477 Nov 5 2018 102140098
drwxr-xr-x 2 user01 root 4096 Nov 3 2018 Desktop/
drwxr-xr-x 2 user01 root 4096 Nov 3 2018 Documents/
drwxr-xr-x 2 user01 root 4096 Nov 3 2018 Downloads/
-rw-r--r-- 1 user01 root 328 Oct 11 15:08 IdentityXXX.pub
drwxr-xr-x 2 user01 root 4096 Nov 3 2018 Music/
drwxr-xr-x 2 user01 root 4096 Nov 3 2018 Pictures/
drwxr-xr-x 2 user01 root 4096 Nov 3 2018 Public/
drwxr-xr-x 2 user01 root 4096 Nov 3 2018 Templates/
drwxr-xr-x 2 user01 root 4096 Nov 3 2018 Videos/
drwxr-xr-x 2 user01 root 4096 Nov 3 2018 document/
drwxr-xr-x 2 user01 root 4096 Mar 6 2019 log/
drwxr-xr-x 3 user01 root 4096 Aug 6 09:06 snort/
drwxr-xr-t 2 user01 root 4096 Nov 3 2018 thinclient_drives/
user01@VMKali:~$
If .ssh folder doesn’t exist then you can use these command to create it!
user01@VMKali:~$ mkdir ~/.ssh
user01@VMKali:~$ chmod 700 ~/.ssh
Create the “authorized_keys” file inside .ssh folder and set the permission on it:
user01@VMKali:~$ touch .ssh/authorized_keys
user01@VMKali:~$ chmod 750 .ssh/authorized_keys
Now that the RSA key is properly formatted, you can add it to the “ authorized_keys”
file.
user01@VMKali:~$ cat IdentityXXX.pub >> .ssh/authorized_keys
user01@VMKali:~$ cat .ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCbyMxD97njbRS+bhRCKhjNGi72fKifWrpW
5TwCY/U8fyQPLzt1v70S2NUPwXKmFTkGNNt5ldgnbQodYUDzCYkN2TOsapRTsQ/4
bgcJz35wGAJGqs4/3XWx3DAGXpi9l0Ys5ch5kTNF9fNK3lb522jxtX9nI7gWywRH
wf/wWHfGBw==
user01@VMKali:~$
3. Bài tập
1) Sử dụng putty hoặc lệnh ssh truy xuất từ xa đến một Server trên Internet sử dụng
khóa công khai và khóa riêng.
-----------------------------------------------------------------