Nextcloud使用OCC命令重置密码

OCC命令的用法
occ命令是ownCloud/Nextcloud的命令行界面。您可以使用occ执行许多常见的服务器操作,例如安装和升级ownCloud/Nextcloud,管理用户,加密,密码,LDAP设置等。

一般格式是这样的:

sudo -u www-data php occ [options] [arguments]

 

重置密码

user相关命令:

 user
  user:add                            添加一个用户
  user:delete                         删除特定用户
  user:disable                        禁用特定用户
  user:enable                         激活特定用户
  user:info                           显示用户信息
  user:lastseen                       显示用户最后登陆了时间
  user:list                           列出所有用户
  user:report                         显示有多少用户访问
  user:resetpassword                  为一个用户重置密码
  user:setting                        读取和修改用户设置

我们需要用的是user:reserpassword。

命令格式为为下

sudo -u www-data php occ user:resetpassword 用户名

实例

要重置密码之前,我们要先知道要给哪个用户重置密码。

sudo -u www-data php occ user:list

重置用户admin的密码

sudo -u www-data php occ user:resetpassword admin

然后会提示输入新密码(输入的密码不会显示)按回车确认密码。

如果输入的密码比较简单,你会得到以下提示,那么你需要换一个更复杂的密码。

重置成功:

Nextcloud/ownCloud去除URL中的index.php详解[转载收藏]

此操作实测是可以的,完美解决

Nextcloud/ownCloud在URL中默认是显示入口文件index.php的:

去除URL中的入口文件有这样3点好处:

  • 拥有一个美观的URL
  • 防止入口文件被篡改,保护网站安全
  • 提高逼格

启用Rewrite

在Ubuntu/Debian中:

a2enmod rewrite #激活mod_rewrite

service apache2 restart #重启apache

在CentOS/RedHat中,需要手动在虚拟主机配置文件中添加以下内容:

LoadModule rewrite_module modules/mod_rewrite.so

然后重启Apache

service apache2 restart

无论方法1还是方法2,都是通过.htaccess中的Rewrite规则来实现的

方法1:config.php+OCC命令

编辑config/config.php

在config.php中设置规则,只需加入以下2行:

'overwrite.cli.url' => 'ownCloud/Nextcloud访问地址',
'htaccess.RewriteBase' => '/',

第一行一般已经存在,可以不再添加,如果和你当前的Nextcloud/ownCloud的访问地址不同,则要修改为当前地址。

以下是一个config.php示例的部分内容,需要添加或修改的两行已用黄色标出

  'overwrite.cli.url' => 'http://192.168.3.3', 
  'dbtype' => 'mysql',
  'version' => '12.0.0.16',
  'dbname' => 'nc',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'user',
  'dbpassword' => 'password',
  'installed' => true,
  'htaccess.RewriteBase' => '/',

现在可以将它保存了。

使用OCC命令生成.htaccess文件

别急着访问Nextcloud,我们只是添加了生成.htaccess的规则而已。现在要使用OCC命令重新生成.htaccess

OCC命令用法:【ownCloud】之终极管理:OCC命令行工具ownCloud/Nextcloud OCC命令行工具详解(1)

使用以下命令生成.htaccess文件:

Ubuntu/Debian类系统

sudo -u www-data php occ maintenance:update:htaccess

CentOS/RedHat:

sudo -u apache php occ maintenance:update:htaccess

如图:

访问你的Nextcloud,index.php已经消失了。

方法2:手动添加规则

打开Nextcloud/ownCloud根目录下的.htaccess文件,在文件最后插入以下内容:

ErrorDocument 403 /core/templates/403.php
ErrorDocument 404 /core/templates/404.php
<IfModule mod_rewrite.c>
  Options -MultiViews
  RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
  RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]
  RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$
  RewriteCond %{REQUEST_FILENAME} !core/img/favicon.ico$
  RewriteCond %{REQUEST_FILENAME} !/remote.php
  RewriteCond %{REQUEST_FILENAME} !/public.php
  RewriteCond %{REQUEST_FILENAME} !/cron.php
  RewriteCond %{REQUEST_FILENAME} !/core/ajax/update.php
  RewriteCond %{REQUEST_FILENAME} !/status.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php
  RewriteCond %{REQUEST_FILENAME} !/robots.txt
  RewriteCond %{REQUEST_FILENAME} !/updater/
  RewriteCond %{REQUEST_FILENAME} !/ocs-provider/
  RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*
  RewriteRule . index.php [PT,E=PATH_INFO:$1]
  RewriteBase /
  <IfModule mod_env.c>
    SetEnv front_controller_active true
    <IfModule mod_dir.c>
      DirectorySlash off
    </IfModule>
  </IfModule>
</IfModule>

保存退出,重新访问Nextcloud,效果与使用OCC命令一样。

一个完整的.htaccess文件:

<IfModule mod_headers.c>
  <IfModule mod_setenvif.c>
    <IfModule mod_fcgid.c>
       SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
       RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    </IfModule>
    <IfModule mod_proxy_fcgi.c>
       SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>
  </IfModule>

  <IfModule mod_env.c>
    # Add security and privacy related headers
    Header set X-Content-Type-Options "nosniff"
    Header set X-XSS-Protection "1; mode=block"
    Header set X-Robots-Tag "none"
    Header set X-Download-Options "noopen"
    Header set X-Permitted-Cross-Domain-Policies "none"
    SetEnv modHeadersAvailable true
  </IfModule>

  # Add cache control for static resources
  <FilesMatch "\.(css|js|svg|gif)$">
    Header set Cache-Control "max-age=15778463"
  </FilesMatch>
  
  # Let browsers cache WOFF files for a week
  <FilesMatch "\.woff$">
    Header set Cache-Control "max-age=604800"
  </FilesMatch>
</IfModule>
<IfModule mod_php5.c>
  php_value upload_max_filesize 511M
  php_value post_max_size 511M
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value always_populate_raw_post_data -1
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_php7.c>
  php_value upload_max_filesize 511M
  php_value post_max_size 511M
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP_USER_AGENT}  DavClnt
  RewriteRule ^$         /remote.php/webdav/          [L,R=302]
  RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L]
  RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
  RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
  RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
  RewriteRule ^remote/(.*) remote.php [QSA,L]
  RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
  RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*
  RewriteRule ^(?:\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
</IfModule>
<IfModule mod_mime.c>
  AddType image/svg+xml svg svgz
  AddEncoding gzip svgz
</IfModule>
<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
  ModPagespeed Off
</IfModule>
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

ErrorDocument 403 /core/templates/403.php
ErrorDocument 404 /core/templates/404.php
<IfModule mod_rewrite.c>
  Options -MultiViews
  RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
  RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]
  RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$
  RewriteCond %{REQUEST_FILENAME} !core/img/favicon.ico$
  RewriteCond %{REQUEST_FILENAME} !/remote.php
  RewriteCond %{REQUEST_FILENAME} !/public.php
  RewriteCond %{REQUEST_FILENAME} !/cron.php
  RewriteCond %{REQUEST_FILENAME} !/core/ajax/update.php
  RewriteCond %{REQUEST_FILENAME} !/status.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php
  RewriteCond %{REQUEST_FILENAME} !/robots.txt
  RewriteCond %{REQUEST_FILENAME} !/updater/
  RewriteCond %{REQUEST_FILENAME} !/ocs-provider/
  RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*
  RewriteRule . index.php [PT,E=PATH_INFO:$1]
  RewriteBase /
  <IfModule mod_env.c>
    SetEnv front_controller_active true
    <IfModule mod_dir.c>
      DirectorySlash off
    </IfModule>
  </IfModule>
</IfModule>

附:NGINX的配置

NGINX和Apache的配置文件不同,所以在NGINX中,上面所述两种方法都是无效的。

NGINX的示例文件

以下是两种NGINX的配置示例,均来自官方文档。

当Nextcloud/ownCloud被安装于根目录时:

upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php5-fpm.sock;
}

server {
    listen 80;
    server_name cloud.example.com;
    # enforce https
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name cloud.example.com;

    ssl_certificate /etc/ssl/nginx/cloud.example.com.crt;
    ssl_certificate_key /etc/ssl/nginx/cloud.example.com.key;

    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
    # add_header Strict-Transport-Security "max-age=15768000;
    # includeSubDomains; preload;";
    #
    # WARNING: Only add the preload option once you read about
    # the consequences in https://hstspreload.org/. This option
    # will add the domain to a hardcoded list that is shipped
    # in all major browsers and getting removed from this list
    # could take several months.
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;

    # Path to the root of your installation
    root /var/www/nextcloud/;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.
    #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
    # last;

    location = /.well-known/carddav {
      return 301 $scheme://$host/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host/remote.php/dav;
    }

    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;

    # Disable gzip to avoid the removal of the ETag header
    gzip off;

    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed off;

    error_page 403 /core/templates/403.php;
    error_page 404 /core/templates/404.php;

    location / {
        rewrite ^ /index.php$uri;
    }

    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
        deny all;
    }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
    }

    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
        #Avoid sending the security headers twice
        fastcgi_param modHeadersAvailable true;
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }

    location ~ ^/(?:updater|ocs-provider)(?:$|/) {
        try_files $uri/ =404;
        index index.php;
    }

    # Adding the cache control header for js and css files
    # Make sure it is BELOW the PHP block
    location ~* \.(?:css|js)$ {
        try_files $uri /index.php$uri$is_args$args;
        add_header Cache-Control "public, max-age=7200";
        # Add headers to serve security related headers (It is intended to
        # have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into
        # this topic first.
        # add_header Strict-Transport-Security "max-age=15768000;
        #  includeSubDomains; preload;";
        #
        # WARNING: Only add the preload option once you read about
        # the consequences in https://hstspreload.org/. This option
        # will add the domain to a hardcoded list that is shipped
        # in all major browsers and getting removed from this list
        # could take several months.
        add_header X-Content-Type-Options nosniff;
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        # Optional: Don't log access to assets
        access_log off;
    }

    location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
        try_files $uri /index.php$uri$is_args$args;
        # Optional: Don't log access to other assets
        access_log off;
    }
}

当Nextcloud/ownCloud被安装于子目录时:

upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php5-fpm.sock;
}

server {
    listen 80;
    server_name cloud.example.com;
    # enforce https
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name cloud.example.com;

    ssl_certificate /etc/ssl/nginx/cloud.example.com.crt;
    ssl_certificate_key /etc/ssl/nginx/cloud.example.com.key;

    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
    #add_header Strict-Transport-Security "max-age=15768000;
    # includeSubDomains; preload;";
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;

    # Path to the root of your installation
    root /var/www/;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.
    # rewrite ^/.well-known/host-meta /nextcloud/public.php?service=host-meta
    # last;
    #rewrite ^/.well-known/host-meta.json
    # /nextcloud/public.php?service=host-meta-json last;

    location = /.well-known/carddav {
      return 301 $scheme://$host/nextcloud/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host/nextcloud/remote.php/dav;
    }

    location /.well-known/acme-challenge { }

    location ^~ /nextcloud {

        # set max upload size
        client_max_body_size 512M;
        fastcgi_buffers 64 4K;

        # Disable gzip to avoid the removal of the ETag header
        gzip off;

        # Uncomment if your server is build with the ngx_pagespeed module
        # This module is currently not supported.
        #pagespeed off;

        error_page 403 /nextcloud/core/templates/403.php;
        error_page 404 /nextcloud/core/templates/404.php;

        location /nextcloud {
            rewrite ^ /nextcloud/index.php$uri;
        }

        location ~ ^/nextcloud/(?:build|tests|config|lib|3rdparty|templates|data)/ {
            deny all;
        }
        location ~ ^/nextcloud/(?:\.|autotest|occ|issue|indie|db_|console) {
            deny all;
        }

        location ~ ^/nextcloud/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param HTTPS on;
            #Avoid sending the security headers twice
            fastcgi_param modHeadersAvailable true;
            fastcgi_param front_controller_active true;
            fastcgi_pass php-handler;
            fastcgi_intercept_errors on;
            fastcgi_request_buffering off;
        }

        location ~ ^/nextcloud/(?:updater|ocs-provider)(?:$|/) {
            try_files $uri/ =404;
            index index.php;
        }

        # Adding the cache control header for js and css files
        # Make sure it is BELOW the PHP block
        location ~* \.(?:css|js)$ {
            try_files $uri /nextcloud/index.php$uri$is_args$args;
            add_header Cache-Control "public, max-age=7200";
            # Add headers to serve security related headers  (It is intended
            # to have those duplicated to the ones above)
            # Before enabling Strict-Transport-Security headers please read
            # into this topic first.
            # add_header Strict-Transport-Security "max-age=15768000;
            # includeSubDomains; preload;";
            add_header X-Content-Type-Options nosniff;
            add_header X-Frame-Options "SAMEORIGIN";
            add_header X-XSS-Protection "1; mode=block";
            add_header X-Robots-Tag none;
            add_header X-Download-Options noopen;
            add_header X-Permitted-Cross-Domain-Policies none;
            # Optional: Don't log access to assets
            access_log off;
        }

        location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
            try_files $uri /nextcloud/index.php$uri$is_args$args;
            # Optional: Don't log access to other assets
            access_log off;
        }
    }
}

Ubuntu nextcloud 视频缩略图视频封面生成

其实这个nextcloud程序视频缩略图有点麻烦,高了几天,也没搞明白,最终问题在哪里,应该是环境配置权限问题, 用宝塔和其他几个主流的LINUX面板套件,装了几次,系统也换了几次,程序能正常安装使用,就是视频缩略图不行,不知道是不是环境权限问题,能想到的,都给了, php-imagick 也安装,ffmpeg 也已经装了, 用 Preview generator 查件查看能正常生成视频缩略图,但是网页端就是加载,显示不了。

官方论坛资官料也找了,

config/config.php added

‘preview_libreoffice_path’ => ‘/etc/libreoffice’,
‘enable_previews’ => true,
‘enabledPreviewProviders’ =>
array (
0 => ‘OC\Preview\TXT’,
1 => ‘OC\Preview\MarkDown’,
2 => ‘OC\Preview\OpenDocument’,
3 => ‘OC\Preview\PDF’,
4 => ‘OC\Preview\MSOffice2003’,
5 => ‘OC\Preview\MSOfficeDoc’,
6 => ‘OC\Preview\PDF’,
7 => ‘OC\Preview\Image’,
8 => ‘OC\Preview\Photoshop’,
9 => ‘OC\Preview\TIFF’,
10 => ‘OC\Preview\SVG’,
11 => ‘OC\Preview\Font’,
12 => ‘OC\Preview\MP3’,
13 => ‘OC\Preview\Movie’,
14 => ‘OC\Preview\MKV’,
15 => ‘OC\Preview\MP4’,
16 => ‘OC\Preview\AVI’,
),

这里也添加了,PSD PDF 都能正常生成。

PHP-FPM env[PATH] 也已经添加

env[PATH] = /usr/local/bin:/usr/bin:/bin:/usr/local/PHP/bin:/usr/lib:/usr

 

WEB用户权限查了,也都没问题

sudo -u www /bin/sh
sh-5.1$ id
用户id=1001(www) 组id=1001(www) 组=1001(www)
sh-5.1$ type ffmpeg
ffmpeg 是 /usr/bin/ffmpeg
sh-5.1$ ffmpeg -version
ffmpeg version 4.3.4-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: –prefix=/usr –extra-version=0+deb11u1 –toolchain=hardened –libdir=/usr/lib/x86_64-linux-gnu –incdir=/usr/include/x86_64-linux-gnu

后来试了 官方的VM虚拟机的系统包,能正常生成缩略图,不是程序问题,也不是后面的配置问题,是宝塔,和其他LINUX面板的WEB环境套件的问题,具体哪里存在问题就不知道了。

 

用官方的VM虚拟机的套件,执行下面之后,然后,config.php 添加previews后,即可正常。

安装扩展:
sudo apt update
sudo apt-get install imagemagick-common
sudo apt-get install php-imagick
sudo apt-get install ffmpeg

还有阿里云里的配套的带NEXTCLOUD套件的系统,也按上面的操作即可。

折腾好几天,太郁闷了。

Ubuntu 更新软件源 阿里源、华为源、清华源

具体步骤如下:
1、使用快捷键【ctrl+alt+t】打开终端。
2、输入以下命令备份原有软件源文件。
cp /etc/apt/sources.list /etc/apt/sources.list.bak_yyyymmdd
3、再输入以下命令打开sources.list文件并添加新的软件源地址。
vim /etc/apt/sources.list #打开sources.list文件

PS: 新安装的Ubuntu可能没有安装Vim, 用如下命令先安装Vim:
sudo apt-get install vim-gtk

在文件末尾添加新的软件源地址,常用国内源地址如下:

#阿里源地址

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

#华为源地址

deb https://repo.huaweicloud.com/ubuntu/ focal main restricted
deb https://repo.huaweicloud.com/ubuntu/ focal-updates main restricted
deb https://repo.huaweicloud.com/ubuntu/ focal universe
deb https://repo.huaweicloud.com/ubuntu/ focal-updates universe
deb https://repo.huaweicloud.com/ubuntu/ focal-backports main restricted universe
deb https://repo.huaweicloud.com/ubuntu/ focal-security main restricted
deb https://repo.huaweicloud.com/ubuntu/ focal-security universe

#中科大源地址

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

#163源地址

deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

#清华源地址

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe ultiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe ultiverse

4、输入命令更新系统软件源地址:
apt-get update
apt-get upgrade
————————————————
版权声明:本文为CSDN博主「anjoel」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/anjoel/article/details/124805571

ubuntu 开启默认ROOT账户登录

1.使用 ubuntu 帐户登录服务器。

2.执行以下命令,设置 root 密码。

sudo passwd root
3.输入 root 的密码,按 Enter。

4.重复输入 root 的密码,按 Enter。

返回如下信息,即表示 root 密码设置成功。

passwd: password updated successfully
5.执行以下命令,打开 sshd_config 配置文件。

sudo vi /etc/ssh/sshd_config

修改,1.

修改 2.

之后按 ESC, 输入 ;wq  保存退出

&nbsp;

&nbsp;

&nbsp;

openssh-server ubuntu 安装不上 安装失败

 

尝试 ,失败

sudo apt-get install ssh-contact-service
正在读取软件包列表… 完成
正在分析软件包的依赖关系树… 完成
正在读取状态信息… 完成
有一些软件包无法被安装。如果您用的是 unstable 发行版,这也许是
因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件
包尚未被创建或是它们已被从新到(Incoming)目录移出。
下列信息可能会对解决问题有所帮助:

下列软件包有未满足的依赖关系:
ssh-contact-service : 依赖: openssh-server
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。

尝试 ,失败

apt-get install openssh-server
正在读取软件包列表… 完成
正在分析软件包的依赖关系树… 完成
正在读取状态信息… 完成
有一些软件包无法被安装。如果您用的是 unstable 发行版,这也许是
因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件
包尚未被创建或是它们已被从新到(Incoming)目录移出。
下列信息可能会对解决问题有所帮助:

下列软件包有未满足的依赖关系:
apt : 依赖: gpgv 或
gpgv2 但是它将不会被安装 或
gpgv1 但是它将不会被安装
依赖: libapt-pkg6.0 (>= 2.4.5) 但是它将不会被安装
bash : 预依赖: libtinfo6 (>= 6) 但无法安装它
dpkg : 预依赖: zlib1g (>= 1:1.1.4) 但无法安装它
fdisk : 依赖: libncursesw6 (>= 6) 但是它将不会被安装
依赖: libreadline8 (>= 6.0) 但是它将不会被安装
依赖: libtinfo6 (>= 6) 但无法安装它
init : 预依赖: systemd-sysv
libbsd0:i386 : 依赖: libc6:i386 (>= 2.25) 但无法安装它
libcbor0.6:i386 : 依赖: libc6:i386 (>= 2.4) 但无法安装它
libedit2:i386 : 依赖: libc6:i386 (>= 2.28) 但无法安装它
libfido2-1:i386 : 依赖: libc6:i386 (>= 2.25) 但无法安装它
libssl1.1:i386 : 依赖: libc6:i386 (>= 2.28) 但无法安装它
libtinfo6:i386 : 依赖: libc6:i386 (>= 2.16) 但无法安装它
libudev1:i386 : 依赖: libc6:i386 (>= 2.30) 但无法安装它
ncurses-bin : 预依赖: libtinfo6 (>= 6.3) 但无法安装它
openssh-client:i386 : 依赖: libc6:i386 (>= 2.28) 但无法安装它
依赖: libgssapi-krb5-2:i386 (>= 1.17) 但无法安装它
依赖: libselinux1:i386 (>= 1.32) 但无法安装它
推荐: xauth:i386
openssh-server : 依赖: procps
依赖: zlib1g (>= 1:1.1.4) 但无法安装它
推荐: default-logind 或
logind 或
libpam-systemd 但是它将不会被安装
推荐: xauth
推荐: ssh-import-id 但是它将不会被安装
shim-signed : 依赖: grub-efi-amd64-signed 但是它将不会被安装 或
grub-efi-arm64-signed 但无法安装它
依赖: grub2-common (>= 2.04-1ubuntu24) 但是它将不会被安装
util-linux : 预依赖: libtinfo6 (>= 6) 但无法安装它
预依赖: libudev1 (>= 183) 但无法安装它
预依赖: zlib1g (>= 1:1.1.4) 但无法安装它
zlib1g:i386 : 依赖: libc6:i386 (>= 2.4) 但无法安装它
E: 错误,pkgProblemResolver::Resolve 发生故障,这可能是有软件包被要求保持现状的缘故。

 

 

后来,发现先卸载, openssh-client   之后再次安装就成功了,

sudo apt-get remove openssh-client

LINUX真是太折腾了,每个软件这个套那个那个套整个,一个出问题,折腾好久才行。