linux-网络相关配置,ssh服务,bash命令及优先级,元字符

linux-网络相关配置,ssh服务,bash命令及优先级,元字符

二:临时配置网络(ip,网关,dns)+永久配置

临时配置:


[[email protected] ~]#
ifconfig

ens32:
flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

inet
192.168.152.134  netmask 255.255.255.0  broadcast 192.168.152.255

inet6
fe80::e33a:cec4:b0d4:c884  prefixlen 64  scopeid 0x20<link>

ether
00:0c:29:f7:dc:59  txqueuelen 1000  (Ethernet)

RX
packets 241828  bytes 275307222 (262.5 MiB)

RX
errors 0  dropped 0  overruns 0  frame 0

TX
packets 7200  bytes 1083100 (1.0 MiB)

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 1  (Local Loopback)

RX
packets 327  bytes 33260 (32.4 KiB)

RX
errors 0  dropped 0  overruns 0  frame 0

TX
packets 327  bytes 33260 (32.4 KiB)

TX
errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[[email protected] ~]#
ifconfig ens32 192.168.152.135

[[email protected] ~]# route
-n

Kernel IP routing table

Destination    
Gateway         Genmask       Flags
Metric Ref   Use Iface

192.168.152.0  
0.0.0.0        
255.255.255.0   U    
0      0        0
ens32

[[email protected] ~]# route
add default gw 192.168.152.2

[[email protected] ~]# route
-n

Kernel IP routing table

Destination    
Gateway         Genmask      
Flags Metric Ref  Use Iface

0.0.0.0        
192.168.152.2  
0.0.0.0         UG   
0      0        0
ens32

192.168.152.0  
0.0.0.0        
255.255.255.0   U    
0      0        0
ens32

[[email protected] ~]# cat
/etc/resolv.conf

# Generated by
NetworkManager

search localdomain

nameserver 192.168.152.2

nameserver 202.106.0.20

永久配置:


[[email protected] ~]# cat
/etc/sysconfig/network-scripts/ifcfg-ens32

TYPE=Ethernet

BOOTPROTO=dhcp

IPADDR=192.168.152.134

NETMASK=255.255.255.0

GATEWAY=192.168.152.2

DNS1=192.168.152.2

DNS2=202.106.0.20

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

IPV6_FAILURE_FATAL=no

IPV6_ADDR_GEN_MODE=stable-privacy

NAME=ens32

UUID=9eff3909-2614-4df9-80c9-a6a7d9f1be28

DEVICE=ens32

ONBOOT=yes

[[email protected] ~]#
systemctl restart network

三:为集群内的机器设定主机名,利用/etc/hosts文件来解析自己的集群中所有的主机名,相应的,集群的配置应该改成使用主机名的方式

修改主机名:

hostname python_web1

cat /etc/hostname

python_web1

修改host文件:

[[email protected]_web1 ~]# cat /etc/hosts

192.168.2.3 python_web1

[[email protected]_web1 ~]# ping python_web1

四:ssh登录,scp上传、下载,ssh秘钥登录,修改ssh
server端的端口为8888然后进行登录和scp测试

SSH登录:


[[email protected] ~]# scp
/etc/hosts web01:/tmp

The authenticity of
host ‘web01 (192.168.152.135)‘ can‘t be established.

ECDSA key
fingerprint is 4c:ee:a3:f1:5c:37:43:32:bd:06:4e:cc:3f:5a:0a:04.

Are you sure you want
to continue connecting (yes/no)? yes

Warning: Permanently
added ‘web01,192.168.152.135‘ (ECDSA) to the list of known hosts.

[email protected]‘s password:

hosts                                                                    
100%  274     0.3KB/s  
00:00

[[email protected] ~]# scp
web01:/tmp/hosts .

[email protected]‘s password:

hosts                                                                    
100%  274     0.3KB/s  
00:00

[[email protected] ~]# ls -l
hosts

-rw-r--r-- 1 root root 274
Mar 21 15:05 hosts

秘钥登录:


[[email protected] ~]#
ssh-keygen

Generating public/private rsa
key pair.

Enter
file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase
(empty for no passphrase):

Enter same passphrase
again:

Your identification has
been saved in /root/.ssh/id_rsa.

Your public key
has been saved in /root/.ssh/id_rsa.pub.

The key
fingerprint is:

29:90:f7:3a:24:0a:e2:f9:22:ec:f4:07:75:7c:10:6b
[email protected]

The key‘s randomart
image is:

+--[ RSA 2048]----+

|      
..        |

|     .
..        |

|    o
oE.        |

|    
+.+ o       |

|o   o +
S        |

|o..o o
o         |

|.+. .
o          |

|ooo  .
.         |

|o..o.           
|

+-----------------+

[[email protected] ~]#
ssh-copy-id -i web01

/usr/bin/ssh-copy-id: INFO:
attempting to log in with the new key(s), to
filter out any that are already installed

/usr/bin/ssh-copy-id: INFO:
1 key(s) remain to be installed -- if you are prompted now
it is to install the new keys

[email protected]‘s password:

Number of key(s) added: 1

Now try logging into the
machine, with:   "ssh ‘web01‘"

and check to make sure that
only the key(s) you wanted were added.

[[email protected] ~]#

[[email protected] ~]#
ssh-copy-id -i web02

The authenticity of
host ‘web02 (192.168.152.136)‘ can‘t be established.

ECDSA key
fingerprint is 4c:ee:a3:f1:5c:37:43:32:bd:06:4e:cc:3f:5a:0a:04.

Are you sure you want to continue connecting
(yes/no)? yes

/usr/bin/ssh-copy-id: INFO:
attempting to log in with the new key(s), to
filter out any that are already installed

/usr/bin/ssh-copy-id: INFO:
1 key(s) remain to be installed -- if you are prompted now
it is to install the new keys

[email protected]‘s password:

Number of key(s) added: 1

Now try logging into the
machine, with:   "ssh ‘web02‘"

and check to make sure that
only the key(s) you wanted were added.

[[email protected] ~]#
ssh-copy-id -i web03

The authenticity of host ‘web03
(192.168.152.137)‘ can‘t be established.

ECDSA key
fingerprint is 4c:ee:a3:f1:5c:37:43:32:bd:06:4e:cc:3f:5a:0a:04.

Are you sure you want
to continue connecting (yes/no)? yes

/usr/bin/ssh-copy-id: INFO:
attempting to log in with the new key(s), to
filter out any that are already installed

/usr/bin/ssh-copy-id: INFO:
1 key(s) remain to be installed -- if you are prompted now
it is to install the new keys

[email protected]‘s password:

Number of key(s) added: 1

Now try logging into the
machine, with:   "ssh ‘web03‘"

and check to make sure that
only the key(s) you wanted were added.

# 修改SSH端口

[[email protected] ~]# ssh
web01

Last login: Tue Mar 21
15:08:30 2017 from proxy-nfs

[[email protected] ~]# sed -i
s‘/^#Port 22/Port 8888/g‘ /etc/ssh/sshd_config

[[email protected] ~]# grep 8888
/etc/ssh/sshd_config

Port 8888

[[email protected] ~]# exit

logout

Connection to web01 closed.

[[email protected] ~]# ssh
web02

Last login: Tue Mar 21
14:53:19 2017 from 192.168.152.1

[[email protected] ~]# sed -i
s‘/^#Port 22/Port 8888/g‘ /etc/ssh/sshd_config

[[email protected] ~]# grep 8888
/etc/ssh/sshd_config

Port 8888

[[email protected] ~]# exit

logout

Connection to web02 closed.

[[email protected] ~]# ssh
web03

Last login: Tue Mar 21
14:53:20 2017 from 192.168.152.1

[[email protected] ~]# sed -i
s‘/^#Port 22/Port 8888/g‘ /etc/ssh/sshd_config

[[email protected] ~]# grep 8888
/etc/ssh/sshd_config

Port 8888

[[email protected] ~]# exit

logout

Connection to web03 closed.

[[email protected] ~]#

# SCP 远程拷贝文件

[[email protected] ~]# touch
oldgirl.txt

[[email protected] ~]# scp
oldgirl.txt web01:/tmp

oldgirl.txt                                                                                                                         
100%    0     0.0KB/s  
00:00

[[email protected] ~]# scp
web01:/etc/passwd .

passwd                                                                                                                              
100% 2375     2.3KB/s   00:00

五:整理bash命令类型,验证寻找一个命令的优先级

# 以ls命令为例

命令分为:

==> alias

  ==> Compound Commands

    ==> function

      ==> build_in

        ==> hash

          ==> $PATH

            ==> error: command not found

获取一个命令会按照上述优先级取寻找,先找同名的alias命令,再找compound命令。。。

 

时间: 2024-11-08 21:35:30

linux-网络相关配置,ssh服务,bash命令及优先级,元字符的相关文章

linux网络相关配置

网络配置文件 IP.MASK.GW.DNS相关配置文件: /etc/sysconfig/network-scripts/ifcfg-IFACE DEVICE:此配置文件应用到的设备,决定设备名 HWADDR:对应的设备的MAC地址 BOOTPROTO:激活此设备时使用的地址配置协议,常用的dhcp----动态, static---静态, none---手动指定, bootp NM_CONTROLLED:NM是NetworkManager的简写,此网卡是否接受NM控制:建议CentOS6"no&q

Linux网络属性配置相关命令

Linux网络属性配置相关命令: 前言: Linux属性配置可以分为两类.一类通过命令配置,另一类通过修改配置文件配置. Linux属性配置的相关命令可以分为三大类: 一.ifcfg命令家族:①ifconfig,②route,③netstat,④hostname ①ifconfig命令:主要负责接口及地址查看和管理 ifconfig [INTERFACE] #ifconfig -a:显示所有接口,包括inactive状态的接口.(包括激活和未激活的接口): 如图所示,-a选项将会显示所有接口,包

Linux网络属性配置命令和管理详解

一.Linux网络属性配置 1.Linux主机接入到网络方式 IP/NETMASK:实现本地网络通信 路由(网关):可以进行跨网络通信 DNS服务器地址:基于主机名的通信,Linux可以有三个DNS地址 当第一个地址本身挂了,才会查找其备用地址:若第一个地址无法解析则停止 2.网络属性配置方式 (1)静态指定 1)命令方式 ifcfg系列命令: ifconfig:配置IP,NETMASK route:配置路由相关信息 netstat:状态及统计数据查看 iiproute2系列命令: ip OBJ

学习笔记之linux网络属性配置及其命令用法

Linux网络属性配置 先来了解一点网络的基础知识:(这些只需记住) TCP/IP:协议栈(使用中的模型) ISO,OSI:协议栈(学习中的模型) MAC:Media Access Control(介质访问控制) 48bits:(48位二进制) ICANN:24bits, 2^24(组织将这个地址做了定义) 地址块:2^24 网桥(bridge):MAC地址表 网桥自身特性: 静态指定: 动态学习:根据原地址学习: 交换机(switch):多端口网桥: IP(Internet protocol互

Linux网络属性配置命令

一.Linux网络属性配置 1.Linux主机接入到网络方式 IP/NETMASK:实现本地网络通信 路由(网关):可以进行跨网络通信 DNS服务器地址:基于主机名的通信,Linux可以有三个DNS地址 当第一个地址本身挂了,才会查找其备用地址:若第一个地址无法解析则停止 2.网络属性配置方式 (1)静态指定 ①命令方式 ifcfg系列命令: ifconfig:配置IP,NETMASK route:配置路由相关信息 netstat:状态及统计数据查看 iiproute2系列命令: ip OBJE

Linux下安装并配置SSH服务

一.使用命令检测Linux系统上是否已经安装了SSH服务:(命令:rpm -qa |grep ssh) 二.如果没有安装SSH软件包,可以通过yum 或rpm安装包进行安装(命令:yum install ssh) 三.安装完成后,启动SSH服务(命令:service sshd start 或 /etc/init.d/sshd start) 四.查看.编辑SSH服务配置文件(命令:vi /etc/ssh/sshd_config) 五.修改其默认端口号,修改为10022 使用VI命令按键盘上的“i”

linux网络相关命令

linux网络相关命令 linux防火墙--netfilter iptables的规则 iptables小案例 原文地址:http://blog.51cto.com/13515599/2065860

Linux 网络相关命令 Cheat Sheet

以下漫画形式呈现的常用 Linux 网络相关命令速查表来自 twitter - ??Julia Evans??@b0rk. 相关资源 twitter - ??Julia Evans??@b0rk 原文地址:https://www.cnblogs.com/Wayou/p/linux_network_commands.html

linux网络相关 |防火墙 |netfilter5表5链

10.11 linux网络相关 ifconfig 如果没有ifconfig,需要安装包 [[email protected] ~]# yum install net-tools 如果需要显示所有的网卡信息,包括down掉的或者没有IP地址的网络,使用-a命令 [[email protected] ~]# ifconfig -a 有时候会单独针对一个网卡做一些更改(如改网关,或者增加DNS),但是不想把所有的网卡都重启,只需要重启指定的网卡,为了避免down掉后无法启动,我们需要2个命令一起执行