Linux ssh server configuration code example

Linux ssh server configuration code example

Use the following terminal command to install the ssh server in the Linux host: sudo apt-get install openssh-server

lin@lin-machine:~$ sudo apt-get install openssh-server
Reading package lists... Done
Building dependency tree    
Reading state information... Done
The following extra packages will be installed:
 libck-connector0 ncurses-term openssh-client openssh-sftp-server
 ssh-import-id
Suggested packages:
 libpam-ssh keychain monkeysphere rssh molly-guard
The following NEW packages will be installed:
 libck-connector0 ncurses-term openssh-server openssh-sftp-server
 ssh-import-id
The following packages will be upgraded:
 openssh-client
1 upgraded, 5 newly installed, 0 to remove and 438 not upgraded.
Need to get 1,180 kB of archives.
After this operation, 3,429 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libck-connector0 amd64 0.4.5-3.1ubuntu2 [10.5 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main openssh-client amd64 1:6.6p1-2ubuntu2.11 [564 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu/ trusty/main ncurses-term all 5.9+20140118-1ubuntu1 [243 kB]
Get:4 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main openssh-sftp-server amd64 1:6.6p1-2ubuntu2.11 [34.1 kB]
Get:5 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main openssh-server amd64 1:6.6p1-2ubuntu2.11 [318 kB]
Get:6 http://cn.archive.ubuntu.com/ubuntu/ trusty/main ssh-import-id all 3.21-0ubuntu1 [9,624 B]
Fetched 1,180 kB in 22s (51.6 kB/s)                      
Preconfiguring packages ...
Selecting previously unselected package libck-connector0:amd64.
(Reading database ... 168838 files and directories currently installed.)
Preparing to unpack .../libck-connector0_0.4.5-3.1ubuntu2_amd64.deb ...
Unpacking libck-connector0:amd64 (0.4.5-3.1ubuntu2) ...
Preparing to unpack .../openssh-client_1%3a6.6p1-2ubuntu2.11_amd64.deb ...
Unpacking openssh-client (1:6.6p1-2ubuntu2.11) over (1:6.6p1-2ubuntu2.7) ...
Selecting previously unselected package ncurses-term.
Preparing to unpack .../ncurses-term_5.9+20140118-1ubuntu1_all.deb ...
Unpacking ncurses-term (5.9+20140118-1ubuntu1) ...
Selecting previously unselected package openssh-sftp-server.
Preparing to unpack .../openssh-sftp-server_1%3a6.6p1-2ubuntu2.11_amd64.deb ...
Unpacking openssh-sftp-server (1:6.6p1-2ubuntu2.11) ...
Selecting previously unselected package openssh-server.
Preparing to unpack .../openssh-server_1%3a6.6p1-2ubuntu2.11_amd64.deb ...
Unpacking openssh-server (1:6.6p1-2ubuntu2.11) ...
Selecting previously unselected package ssh-import-id.
Preparing to unpack .../ssh-import-id_3.21-0ubuntu1_all.deb ...
Unpacking ssh-import-id (3.21-0ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Processing triggers for ufw (0.34~rc-0ubuntu2) ...
Setting up libck-connector0:amd64 (0.4.5-3.1ubuntu2) ...
Setting up openssh-client (1:6.6p1-2ubuntu2.11) ...
Setting up ncurses-term (5.9+20140118-1ubuntu1) ...
Setting up openssh-sftp-server (1:6.6p1-2ubuntu2.11) ...
Setting up openssh-server (1:6.6p1-2ubuntu2.11) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
Creating SSH2 ED25519 key; this may take some time ...
ssh start/running, process 17527
Setting up ssh-import-id (3.21-0ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.9) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for ufw (0.34~rc-0ubuntu2) ...

View the current virtual machine's IP address

lin@lin-machine:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:f1:a1:37 
     inet addr:192.168.147.136 Bcast:192.168.147.255 Mask:255.255.255.0
     inet6 addr: fe80::20c:29ff:fef1:a137/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
     RX packets:3950 errors:0 dropped:0 overruns:0 frame:0
     TX packets:514 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000 
     RX bytes:1453734 (1.4 MB) TX bytes:63371 (63.3 KB)

lo Link encap:Local Loopback 
     inet addr:127.0.0.1 Mask:255.0.0.0
     inet6 addr: ::1/128 Scope:Host
     UP LOOPBACK RUNNING MTU:65536 Metric:1
     RX packets:180 errors:0 dropped:0 overruns:0 frame:0
     TX packets:180 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1 
     RX bytes: 13377 (13.3 KB) TX bytes: 13377 (13.3 KB)

Check the IP address on the PC

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
E:\Users\libra>ipconfig
Windows IP Configuration...
Ethernet Adapter VMware Network Adapter VMnet8:

  Connect to a specific DNS suffix. . . . . . :
  Link-local IPv6 address . . . . . . . : fe80::9074:b9f5:ddaf:9082%25
  IPv4 address . . . . . . . . . . . : 192.168.147.1
  Subnet mask . . . . . . . . . . . : 255.255.255.0
  Default gateway . . . . . . . . . . . . :
...
E:\Users\libra>

[Note] PC and Linux virtual machine are in the same network segment

Test if they can ping

lin@lin-machine:~$ ping 192.168.147.1
PING 192.168.147.1 (192.168.147.1) 56(84) bytes of data.
64 bytes from 192.168.147.1: icmp_seq=1 ttl=64 time=0.586 ms
64 bytes from 192.168.147.1: icmp_seq=2 ttl=64 time=0.442 ms
64 bytes from 192.168.147.1: icmp_seq=3 ttl=64 time=0.435 ms
^C
--- 192.168.147.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.435/0.487/0.586/0.074 ms 

[There may be some abnormal reasons] Note: Windows 7 has the system firewall turned on by default, which prohibits ping. If you ping Windows in Linux
7, you need to turn off the Windows 7 firewall first.

After there are no problems, we start testing on SecureCRT

[Note] Write the IP and host name according to your own situation

Let’s test it

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Tutorial on configuring SSH and Xshell to connect to the server in Linux (with pictures)
  • How to set up ssh password-free login to Linux server
  • Linux server SSH cracking prevention method (recommended)
  • Install OpenSSH on Windows and log in to the Linux server by generating an SSH key
  • How to upload files and folders to Linux server via SSH
  • Paramiko module under Python implements ssh connection to log in to Linux server
  • Using winscp and batch processing under Windwos to upload files to Linux server through SSH port
  • Four tips for configuring secure SSH access on Linux servers

<<:  Usage of Vue filters and timestamp conversion issues

>>:  In-depth explanation of binlog in MySQL 8.0

Recommend

HTML drawing user registration page

This article shares the specific implementation c...

How to create a table by month in MySQL stored procedure

Without going into details, let's go straight...

Tutorial for installing MySQL 8.0.18 under Windows (Community Edition)

This article briefly introduces how to install My...

MySQL-8.0.26 Configuration Graphics Tutorial

Preface: Recently, the company project changed th...

Solve the problem of garbled data in MySQL database migration

Under the instructions of my leader, I took over ...

JS implements Baidu search box

This article example shares the specific code of ...

Detailed explanation of the solution for migrating antd+react projects to vite

Antd+react+webpack is often the standard combinat...

JavaScript explains the encapsulation and use of slow-motion animation

Implementing process analysis (1) How to call rep...

Let's talk about bitwise operations in React source code in detail

Table of contents Preface Several common bit oper...

A very detailed explanation of Linux C++ multi-thread synchronization

Table of contents 1. Mutex 1. Initialization of m...

An article to understand the use of proxies in JavaScript

Table of contents What is an agent Basic knowledg...

MySQL 5.7.20 zip installation tutorial

MySQL 5.7.20 zip installation, the specific conte...

Cross-database association query method in MySQL

Business scenario: querying tables in different d...