远程访问,文件的压缩,ip地址的设置(9,11,12unit)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了远程访问,文件的压缩,ip地址的设置(9,11,12unit)相关的知识,希望对你有一定的参考价值。


第九单元——远程访问

1.什么是openssh

是一个提供远程访问控制的软件

2.如何实现远程访问

ssh 远程主机用户@远程主机ip地址

ssh [email protected]

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

ECDSA key fingerprint is 55:dd:43:ce:bf:94:dd:91:49:e7:97:29:63:3d:02:02.

Are you sure you want to continue connecting (yes/no)? yes /*建立安全传输key

[email protected]‘s password: /*密码输入没有回显

Last failed login: Sun Oct 11 16:56:29 CST 2015 from 172.25.254.206 on ssh:notty

There was 1 failed login attempt since the last successful login.

Last login: Sun Oct 11 16:55:46 2015 from 172.25.254.206

[[email protected] ~]# /*登陆成功

ctrl +d |logout ###退出

[[email protected] ~]# logout

Connection to 172.25.254.1 closed.

[[email protected] ~]# vim /etc/motd /*设定登陆显示字符

3.ssh的key认证

#######生成key###########

[[email protected] ~]$ ssh-keygen /*生成公钥和私钥的工具

Generating public/private rsa key pair.(绿色字体为自动生成过程)

Enter file in which to save the key (/home/test/.ssh/id_rsa):『enter』 ###指定加密字符保存文件,使用默认

Created directory ‘/home/test/.ssh‘.

Enter passphrase (empty for no passphrase): ###密码,必须大于4位

Enter same passphrase again:

Your identification has been saved in /home/test/.ssh/id_rsa.

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

The key fingerprint is: ###确认密码

a5:4f:02:51:68:59:f4:e8:e3:c5:91:1f:6f:86:99:06 [email protected]

The key‘s randomart image is:

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

| .*+ |

| +. o . |

| .. . E . |

| o + + * |

| S + * + |

| . * . o |

| . . |

| |

| |

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

[[email protected] .ssh]$ pwd

/home/test/.ssh ###生成密钥存放位置

[[email protected] .ssh]$ ls

id_rsa id_rsa.pub ####id_rsa位私钥,id_rsa.pub位公钥

#####################使用key加密目标主机的目标用户############

[[email protected] ~]$ ssh-copy-id -i /home/test/.ssh/id_rsa.pub [email protected]

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

ECDSA key fingerprint is eb:24:0e:07:96:26:b1:04:c2:37:0c:78:2d:bc:b0:08.

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

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

installed

/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 ‘[email protected]‘"

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

ssh-copy-id #### 上传key的工具

-i ####指定使用的公钥

/home/test/.ssh/id_rsa.pub /*使用公钥的名称

westos              /*被管理的目标用户

172.25.254.100         /*被管理用户所在主机的ip

authorized_keys        /*此文件在目标用户加目录的.ssh中,这个文件就是目标用户被加密的标                    识,文件内容位公钥内容。

4.sshd服务的简单配置

vim /etc/ssh/sshd_config      /*sshd服务的配置文件

48 PermitRootLogin yes|no     /*是否允许root用户通过sshd的认证

78 PasswordAuthentication yes|no /*开启或关闭用户密码认证

AllowUsers student westos     /*用户白名单,只允许在名单中出现的用户使用sshd服务(当白名单为空时,所有人不得访问)

DenyUsers westos            /*用户黑名单

systemctl restart sshd        /*从新加载配置(每次修改sshd文件后,需要重新启动



第十二单元-----文件的压缩和远程传递

1.文件压缩:即文档归档,就是把多个文件变成一个归档文件.

tar     c     /*创建

      f     /*指定归档文件的名称

     t     /*显示归档文件的内容

     r     /*向归档文件中添加内容

     --get   /*取出归档文件中的单个文件

     --delete  /*删除归档文件中的单个文件

     x     /*取出归档文件中的所有内容

     -C    /*指定解档目录

     -z     /*gz格式压缩

     -j     /*z2格式压缩

     -J     /*xz格式压缩

2.压缩和解压格式

gz

gzip file.tar.            /*压缩成gz格式

gungzip file.tar.gz         /*解压gz格式的压缩包

du-sh file.tar.gz            /*参看文件大小

tar zcf file.tar.gz /file     /*把文档归档为tar并压缩为gz

tar zxf file.tar.gz        /*解压解档gz格式压缩包

bz2

bzip2 file.tar           /*压缩成bz2格式

bunzip2 file.tar.bz2         /*解压bz2格式的压缩包

tar jcf file.tar.bz2 /file     /*把文档归档为tar并压缩成bz2

tar jxf file.tar.bz2        /*解压并解档bz2格式压缩bz2

zip

zip -r file.tar.zip file.tar   /*压缩成zip格式

unzip file.tar.zip         /*解压zip格式的压缩包

xz

xz file.tar             /*压缩成xz格式

unxz file.tar.xz           /*解压xz格式的压缩包

tar Jcf file.tar.xz /file      /*把文件归档为tar并压缩成zx

tar Jxf file.tar.xz          /*解压并归档xz格式压缩包

3.系统中文件远程传输

scp /*远程复制

scp file [email protected]:/directory /*上传文件

scp -r dir [email protected]:/directory /*长传目录

scp [email protected]:/filename /direcotry /*下载文件

scp -r [email protected]:/directory /direcotry /*下载目录

rsync /*远程同步

rsync file|direcotry [email protected]:/directory

rsync [email protected]:/directory /directory

rsync [参数] file [email protected]:/dir

    -r     /*同步目录

    -l     /*不忽略链接

    -p     /*不忽略文件权限

    -t     /*不忽略文件时间戳

    -g     /*不忽略文件所有组

    -o     /*不忽略文件所有人

    -d     /*不忽略块设备

第十一单元ip地址的设置

1.ip基础知识

  1. ipv4:二进制32位

  2. 172.25.0.10/255.255.255.0

    ipaddr 172.25.0.10

    子网掩码:255.255.255.0

    子网掩码255位对应的ip位的网络位

    子网掩码0对应的ip的主机位

2.配置ip

  1. 图形界面:nm-connection-editor

  2. 文本界面:nmtui

  3. 命令配置ip

    ifconfig 网卡 ip netmask 临时设定

    nmcli connection add type ethernet con-name westos ifname eth0 autoconnect yes/*添加动态网

    nmcli connection add type ethernet con-name westos ifname eth0 ip4 ip/24/*静态网

    nmcli connection delete westos

    nmcli connection show

    nmcli connection down westos

    nmcli connection up westos

    nmcli connection modify"westos "ipv4.addresses newip/24

    nmcli connection modify"westos eth0"ipv4.method <auto|manual>

    nmcli device connect eth0

    nmcli device disconnect eth0

    nmcli device  show

    nmcli device  status 

  4. 网络配置文件

    /etc/sysconfig/network-scripts/   /*网络配置目录

  5. 文件的方式编辑ip()

    1)###动态网络配置###

    vim ifcfg-xxx      /*网络配置文件格式

    DEVICE=eth0       /*指定文件管理的设备名称

    BOOTPROTO=dhcp     /*dhcp动态获取,none和static都表示静态网络

    ONBOOT=yes        /*开机自动激活设备

    NAME=hello        /*指定网络链接的名字为hello

    2)###静态网络配置###(可以设置多个ip地址

    vim ifcfg-xxx          /*网络配置文件格式

    DEVICE=eth0            /*指定文件管理的设备名称

    BOOTPROTO=static|none dhcp  /*动态获取,none和static都表示静态网络

    ONBOOT=yes             /*开机自动激活设备

    NAME=hello             /*指定链接名字

    IPADDR=172.25.254.100      /*设定ip为172.25.254.100

    NETMASK=255.255.255.0      /*子网掩码为255.255.255.0

    PREFIX=24              /*子网掩码为255.255.255.0

技术分享

技术分享


以上是关于远程访问,文件的压缩,ip地址的设置(9,11,12unit)的主要内容,如果未能解决你的问题,请参考以下文章

MariaDB(mysql)远程访问设置

如何限制IP地址设置指定IP地址访问windows远程桌面主机

如何设置PostgreSQL允许被远程访问

服务器安全检测提示“关闭远程访问或限制访问的ip地址” 怎么关闭呢?阿里云的服务器

如何配置sqlserver 设置远程访问

邮件访问被拒绝因为没有授权此用户远程登录什么意思