服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Linux - Linux ssh服务器配置代码实例

Linux ssh服务器配置代码实例

2020-09-17 22:58陌鉎こ城sHi Linux

这篇文章主要介绍了Linux ssh服务器配置代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

使用如下终端命令可以在 Linux 主机中安装 ssh服务器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) ...

 

查看当前的虚拟机的ip地址

 

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)

 

在PC上查看ip地址

 

Microsoft Windows [版本 6.1.7601] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

	E:\Users\libra>ipconfig

	Windows IP 配置

	...

	以太网适配器 VMware Network Adapter VMnet8:

 

 

连接特定的 DNS 后缀 . . . . . . . :

	本地链接 IPv6 地址. . . . . . . . : fe80::9074:b9f5:ddaf:9082%25

	IPv4 地址 . . . . . . . . . . . . : 192.168.147.1

	子网掩码 . . . . . . . . . . . . : 255.255.255.0

	默认网关. . . . . . . . . . . . . :

	...

	E:\Users\libra>

 

【备注】pc和linux虚拟机在同个网段的

测试他们是否可以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

 

Linux ssh服务器配置代码实例

【可能存在一些异常的原因】注意: Windows 7 默认打开了系统防火墙,是禁ping的,如果在Linux下ping Windows
7,需要先关闭Windows 7 的防火墙。

没有问题后我们在SecureCRT上开始测试

Linux ssh服务器配置代码实例

Linux ssh服务器配置代码实例

【备注】根据自己的情况来写IP和主机名

Linux ssh服务器配置代码实例

来测试一下

Linux ssh服务器配置代码实例

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://www.cnblogs.com/libra13179/p/10172482.html

延伸 · 阅读

精彩推荐
  • Linux手把手教您在 Linux 上使用 GPG 加解密文件

    手把手教您在 Linux 上使用 GPG 加解密文件

    在本教程中,我将告诉你如何用 GPG 加密和解密文件。这是一个简单的教程,你可以在你的 Linux 系统上尝试所有的练习。这将帮助你练习 GPG 命令,并在你...

    Linux中国6962021-12-15
  • Linuxlinux中rmdir命令使用详解(删除空目录)

    linux中rmdir命令使用详解(删除空目录)

    今天学习一下linux中命令: rmdir命令。rmdir是常用的命令,该命令的功能是删除空目录,一个目录被删除之前必须是空的 ...

    linux命令大全5372019-11-19
  • LinuxLinux上设置用户通过SFTP访问目录的权限的方法

    Linux上设置用户通过SFTP访问目录的权限的方法

    这篇文章主要介绍了Linux上设置用户通过SFTP访问目录的权限的方法,SFTP可以理解为使用SSH协议进行FTP传输的协议,因而同时要对OpenSSH进行相关设置,需要的朋...

    OSChina10022019-06-19
  • LinuxLinux中环境变量配置的步骤详解

    Linux中环境变量配置的步骤详解

    Linux中环境变量包括系统级和用户级,系统级的环境变量是每个登录到系统的用户都要读取的系统变量,而用户级的环境变量则是该用户使用系统时加载的...

    Myths7882022-02-10
  • LinuxLinux lnmp下无法使用mail发邮件的两种解决方法

    Linux lnmp下无法使用mail发邮件的两种解决方法

    在配置了lnmp环境后,出现了mail函数不能发送邮件的问题,其实有两种方法,一是使用sendmail组件,而是使用postfix。下面为大家一一介绍下 ...

    Linux之家4042019-09-17
  • Linux详解Linux系统下PXE服务器的部署过程

    详解Linux系统下PXE服务器的部署过程

    这篇文章主要介绍了Linux系统下PXE服务器的部署过程,包括对PXE的API架构作了一个基本的简介,需要的朋友可以参考下...

    运维之道9812019-07-04
  • Linux确保Linux系统安全的前提条件 漏洞防护

    确保Linux系统安全的前提条件 漏洞防护

    Linux 作为开放式的操作系统受到很多程序员的喜爱,很多高级程序员都喜欢编写Linux操作系统的相关软件。这使得Linux操作系统有着丰富的软件支持,还有无...

    Linux之家2642020-04-11
  • LinuxLinux常用的日志文件和常用命令

    Linux常用的日志文件和常用命令

    成功地管理任何系统的关键之一,是要知道系统中正在发生什么事。 Linux 中提供了异常日志,并且日志的细节是可配置的。Linux 日志都以明文形式存储,所...

    Linux教程网2632020-04-18