Install ssh di Ubuntu 20.04

Dari Dokumentasi Robie
Loncat ke navigasi Loncat ke pencarian

Anggap saja kita baru pertama kali menginstall sistem operasi linux dan belum melakukan konfigurasi apa-apa setelah berhasil melakukan install. SSH (Secure Shell) sendiri adalah protocol yang digunakan untuk melakukan remote server yang menggunakan ip address dan aplikasi ssh sebagai akses masuknya. Untuk melakukan instalasi SSH dapat melakukan perintah berikut:

Install

$sudo apt-get update
$sudo apt-get install openssh-server
$ sudo apt-get install openssh-server
[sudo] password for robie: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  openssh-client openssh-sftp-server
Suggested packages:
  keychain libpam-ssh monkeysphere ssh-askpass molly-guard
The following packages will be upgraded:
  openssh-client openssh-server openssh-sftp-server
3 upgraded, 0 newly installed, 0 to remove and 158 not upgraded.
Need to get 1100 kB of archives.
After this operation, 9216 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://id.archive.ubuntu.com/ubuntu focal-updates/main amd64 openssh-sftp-server amd64 1:8.2p1-4ubuntu0.9 [51.7 kB]
Get:2 http://id.archive.ubuntu.com/ubuntu focal-updates/main amd64 openssh-server amd64 1:8.2p1-4ubuntu0.9 [377 kB]
Get:3 http://id.archive.ubuntu.com/ubuntu focal-updates/main amd64 openssh-client amd64 1:8.2p1-4ubuntu0.9 [671 kB]
Fetched 1100 kB in 1min 47s (10.3 kB/s)                                        
Preconfiguring packages ...
(Reading database ... 73081 files and directories currently installed.)
Preparing to unpack .../openssh-sftp-server_1%3a8.2p1-4ubuntu0.9_amd64.deb ...
Unpacking openssh-sftp-server (1:8.2p1-4ubuntu0.9) over (1:8.2p1-4ubuntu0.7) ...
Preparing to unpack .../openssh-server_1%3a8.2p1-4ubuntu0.9_amd64.deb ...
Unpacking openssh-server (1:8.2p1-4ubuntu0.9) over (1:8.2p1-4ubuntu0.7) ...
Preparing to unpack .../openssh-client_1%3a8.2p1-4ubuntu0.9_amd64.deb ...
Unpacking openssh-client (1:8.2p1-4ubuntu0.9) over (1:8.2p1-4ubuntu0.7) ...
Setting up openssh-client (1:8.2p1-4ubuntu0.9) ...
Setting up openssh-sftp-server (1:8.2p1-4ubuntu0.9) ...
Setting up openssh-server (1:8.2p1-4ubuntu0.9) ...
rescue-ssh.target is a disabled or a static unit, not starting it.
Processing triggers for systemd (245.4-4ubuntu3.17) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for ufw (0.36-6ubuntu1) ...
robie@robie:~$ 

Restart

/etc/init.d/ssh restart


Untuk melakukan remote SSH kita perlu mengetahui IP Address yang akan di remote. Cara melihat IP Address di Linux Ubuntu 20.04 dengan mengetikan perintah

ifconfig lalu enter

hasilnya akan terlihat seperti berikut

~$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 192.168.122.140  netmask 255.255.255.0  broadcast 192.168.122.255
       inet6 fe80::a00:27ff:febf:ea8e  prefixlen 64  scopeid 0x20<link>
       ether 08:00:27:bf:ea:8e  txqueuelen 1000  (Ethernet)
       RX packets 16745  bytes 22061193 (22.0 MB)
       RX errors 0  dropped 908  overruns 0  frame 0
       TX packets 11177  bytes 929689 (929.6 KB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
       inet 127.0.0.1  netmask 255.0.0.0
       inet6 ::1  prefixlen 128  scopeid 0x10<host>
       loop  txqueuelen 1000  (Local Loopback)
       RX packets 4137  bytes 195200 (195.2 KB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 4137  bytes 195200 (195.2 KB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


Gunakan PC/Laptop lain menggunakan sistem operasi linux dengan jaringan yang sama untuk meremote IP yang bercetak tebal diatas, dengan mengetikkan perintah berikut


$ ssh [email protected] lalu tekan enter

untuk pertama kali menggunakan ssh akan terlihat hasilnya sebagai berikut

$ ssh [email protected]
The authenticity of host '192.168.122.140 (192.168.122.140)' can't be established.
ED25519 key fingerprint is SHA256:j/9duRIR6FZOg1idzOEUqx4tBwUJkHPbKg68sktfXiA.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.122.140' (ED25519) to the list of known hosts.
[email protected]'s password: 
Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.4.0-150-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue 19 Sep 2023 06:44:46 AM UTC

  System load:  0.0               Processes:               122
  Usage of /:   45.1% of 9.75GB   Users logged in:         1
  Memory usage: 13%               IPv4 address for enp0s3: 192.168.122.140
  Swap usage:   0% 


164 updates can be applied immediately.
116 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable 

New release '22.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it. 


Last login: Tue Sep 19 06:38:33 2023 from 192.168.122.1
robie@robie:~$


Jika sudah menggunakan ssh yang kedua kali dan seterusnya akan muncul tampilan seperti berikut

~$ ssh [email protected]
[email protected]'s password: 
Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.4.0-150-generic x86_64)
* Documentation:  https://help.ubuntu.com
* Management:     https://landscape.canonical.com
* Support:        https://ubuntu.com/advantage
  System information as of Tue 19 Sep 2023 06:38:32 AM UTC
  System load:  0.0               Processes:               117
  Usage of /:   45.1% of 9.75GB   Users logged in:         1
  Memory usage: 12%               IPv4 address for enp0s3: 192.168.122.140
  Swap usage:   0%
164 updates can be applied immediately.
116 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
New release '22.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Tue Sep 19 06:34:05 2023 from 192.168.122.1
robie@robie:~$

Jika sudah muncul seperti ini artinya kita sudah berhasil masuk ke dalam server Ubuntu dengan IP 192.168.122.140.