1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 【Linux operation 48】Ubuntu启用root用户 并授予远程ssh访问权限

【Linux operation 48】Ubuntu启用root用户 并授予远程ssh访问权限

时间:2019-10-16 14:09:27

相关推荐

【Linux operation 48】Ubuntu启用root用户 并授予远程ssh访问权限

ubuntu系统服务器,默认的登陆用户名为ubuntu,那很多用户都想使用超级管理员root用户来操作自己的服务器,但是root用户默认是被禁止登陆的,该如何启用root用户呢?操作方法如下:

1、使用自己创建的 ubuntu 帐户登录应用服务器

2、设置 root 密码

sudo passwd root

输入两遍密码;

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

passwd: password updated successfully

3、下载vim、ssh服务

sudo apt install vimsudo apt install ssh

root@test-virtual-machine:/etc/ssh# apt install vimReading package lists... DoneBuilding dependency tree... DoneReading state information... DoneThe following additional packages will be installed:vim-common vim-runtime vim-tinySuggested packages:ctags vim-doc vim-scripts indentThe following NEW packages will be installed:vim vim-runtimeThe following packages will be upgraded:vim-common vim-tiny2 upgraded, 2 newly installed, 0 to remove and 70 not upgraded.Need to get 8,560 kB/9,345 kB of archives.After this operation, 37.6 MB of additional disk space will be used.Do you want to continue? [Y/n] yGet:1 http://cn./ubuntu jammy-updates/main amd64 vim-runtime all 2:8.2.3995-1ubuntu2.1 [6,832 kB]Get:2 http://cn./ubuntu jammy-updates/main amd64 vim amd64 2:8.2.3995-1ubuntu2.1 [1,727 kB]Fetched 8,560 kB in 3s (2,712 kB/s)(Reading database ... 195574 files and directories currently installed.)Preparing to unpack .../vim-tiny_2%3a8.2.3995-1ubuntu2.1_amd64.deb ...Unpacking vim-tiny (2:8.2.3995-1ubuntu2.1) over (2:8.2.3995-1ubuntu2) ...Preparing to unpack .../vim-common_2%3a8.2.3995-1ubuntu2.1_all.deb ...Unpacking vim-common (2:8.2.3995-1ubuntu2.1) over (2:8.2.3995-1ubuntu2) ...Selecting previously unselected package vim-runtime.Preparing to unpack .../vim-runtime_2%3a8.2.3995-1ubuntu2.1_all.deb ...Adding 'diversion of /usr/share/vim/vim82/doc/help.txt to /usr/share/vim/vim82/doc/help.txt.vim-tiny by vim-runtime'Adding 'diversion of /usr/share/vim/vim82/doc/tags to /usr/share/vim/vim82/doc/tags.vim-tiny by vim-runtime'Unpacking vim-runtime (2:8.2.3995-1ubuntu2.1) ...Selecting previously unselected package vim.Preparing to unpack .../vim_2%3a8.2.3995-1ubuntu2.1_amd64.deb ...Unpacking vim (2:8.2.3995-1ubuntu2.1) ...Setting up vim-common (2:8.2.3995-1ubuntu2.1) ...Setting up vim-runtime (2:8.2.3995-1ubuntu2.1) ...Setting up vim (2:8.2.3995-1ubuntu2.1) ...update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto modeupdate-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto modeupdate-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto modeupdate-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview)in auto modeupdate-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto modeupdate-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto modeupdate-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto modeSetting up vim-tiny (2:8.2.3995-1ubuntu2.1) ...Processing triggers for mailcap (3.70+nmu1ubuntu1) ...Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...Processing triggers for hicolor-icon-theme (0.17-2) ...Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...Processing triggers for man-db (2.10.2-1) ...

root@test-virtual-machine:/etc/ssh# apt install sshReading package lists... DoneBuilding dependency tree... DoneReading state information... DoneThe following additional packages will be installed:ncurses-term openssh-server openssh-sftp-server ssh-import-idSuggested packages:molly-guard monkeysphere ssh-askpassThe following NEW packages will be installed:ncurses-term openssh-server openssh-sftp-server ssh ssh-import-id0 upgraded, 5 newly installed, 0 to remove and 70 not upgraded.Need to get 756 kB of archives.After this operation, 6,179 kB of additional disk space will be used.Do you want to continue? [Y/n] yGet:1 http://cn./ubuntu jammy/main amd64 openssh-sftp-server amd64 1:8.9p1-3 [38.8 kB]Get:2 http://cn./ubuntu jammy/main amd64 openssh-server amd64 1:8.9p1-3 [434 kB]Get:3 http://cn./ubuntu jammy/main amd64 ssh all 1:8.9p1-3 [4,834 B]Get:4 http://cn./ubuntu jammy/main amd64 ncurses-term all 6.3-2 [267 kB]Get:5 http://cn./ubuntu jammy/main amd64 ssh-import-id all 5.11-0ubuntu1 [10.1 kB]Fetched 756 kB in 3s (264 kB/s)Preconfiguring packages ...Selecting previously unselected package openssh-sftp-server.(Reading database ... 197515 files and directories currently installed.)Preparing to unpack .../openssh-sftp-server_1%3a8.9p1-3_amd64.deb ...Unpacking openssh-sftp-server (1:8.9p1-3) ...Selecting previously unselected package openssh-server.Preparing to unpack .../openssh-server_1%3a8.9p1-3_amd64.deb ...Unpacking openssh-server (1:8.9p1-3) ...Selecting previously unselected package ssh.Preparing to unpack .../ssh_1%3a8.9p1-3_all.deb ...Unpacking ssh (1:8.9p1-3) ...Selecting previously unselected package ncurses-term.Preparing to unpack .../ncurses-term_6.3-2_all.deb ...Unpacking ncurses-term (6.3-2) ...Selecting previously unselected package ssh-import-id.Preparing to unpack .../ssh-import-id_5.11-0ubuntu1_all.deb ...Unpacking ssh-import-id (5.11-0ubuntu1) ...Setting up openssh-sftp-server (1:8.9p1-3) ...Setting up openssh-server (1:8.9p1-3) ...Creating config file /etc/ssh/sshd_config with new versionCreating SSH2 RSA key; this may take some time ...3072 SHA256:8GWMrs0KbgauxIy3zIrN3L+ZS4Pdv9X30sJ81Pm8Xr4 root@test-virtual-machine (RSA)Creating SSH2 ECDSA key; this may take some time ...256 SHA256:7TK7qy8o1RM+MtD+7GcJtp07b3843uHNm84XUIdY1W8 root@test-virtual-machine (ECDSA)Creating SSH2 ED25519 key; this may take some time ...256 SHA256:MozIziCL1cvOtJDgHeP2O/Wu+stbjpfFQTeXpkxmuzA root@test-virtual-machine (ED25519)Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service.Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/systemd/system/ssh.service.rescue-ssh.target is a disabled or a static unit, not starting it.ssh.socket is a disabled or a static unit, not starting it.Setting up ssh-import-id (5.11-0ubuntu1) ...Setting up ncurses-term (6.3-2) ...Setting up ssh (1:8.9p1-3) ...Processing triggers for man-db (2.10.2-1) ...Processing triggers for ufw (0.36.1-4build1) ...

4、开启root用户ssh远程密码登录

编辑/etc/ssh/sshd_config文件

sudo vim /etc/ssh/sshd_config

将PermitRootLogin prohibit-password更改为:PermitRootLogin yes

最后重启ssh服务即可

sudo systemctl restart ssh

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。