Linux常用笔记

  • 2020-01-07
  • 40
  • 0

前言

主要是记录自己再使用linux操作系统和容器相关技术时,经常会使用到的配置,网站等.
此文档不定时更新. 非常不定时.

阿里的源

Centos

源文件目录:

/etc/yum.repo.d/CentOs-Base.repo

替换阿里yum源:

cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak //备份原有的源.
wget -O CentOs-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

更新:

yum clean all
yum makecache
yum update

Ubuntu/Debian

ubuntu源文件目录:

/etc/apt/source.list

替换为阿里源:

//备份:
cp /etc/apt/sources.list /etc/apt/sources.list.bak


#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

自己做了一个脚本:
wget https://raw.githubusercontent.com/cynen/linux-scripts/master/sources/apt-sources

docker的阿里源.

使用阿里的docker源之后,安装yum install docker时,下载速度飞快.

# Set up repository
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

# Use Aliyun Docker
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

Linux使用笔记

sshd链接不上.

在服务器上安装好Centos操作系统后,准备使用ssh链接到服务器上进行操作.
结果报错:

主要解决办法依赖日志比较靠谱.网上搜了一大堆,最后不如看一下日志. 但是sshd服务的日志路径是有讲究的哈. 各个博客有不同的地址.
1. 使用systemctl status ssd -l
可以看到一些详略信息,基于此,可以解决一定的问题. 比如我的直接报错key权限不对. 私钥必须配置 600权限,不可再给其他组和人开放权限.

error: bad permissions: ignore key: /etc/ssh/ssh_host_ecdsa_key
  1. 查看详细日志:
    针对Centos的sshd日志文件是:/var/log/secure
cat /var/log/secure 
...
Jan  9 13:37:07 localhost polkitd[4804]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Jan  9 13:37:08 localhost sshd[5076]: Server listening on 0.0.0.0 port 22.
Jan  9 13:37:08 localhost sshd[5076]: Server listening on :: port 22.
Jan  9 13:37:20 localhost login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)
Jan  9 13:37:20 localhost login: ROOT LOGIN ON tty1
Jan  9 13:37:40 localhost sshd[5598]: Address 172.16.21.64 maps to bogon, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
Jan  9 13:37:40 localhost sshd[5598]: Accepted password for root from 172.16.21.64 port 50236 ssh2
Jan  9 13:37:41 localhost sshd[5598]: pam_unix(sshd:session): session opened for user root by (uid=0)
...

这里可以解决大部分问题.

0

评论

还没有任何评论,你来说两句吧