記錄一下Ubuntu17.10的openssh-server的安裝和使用。安裝之後就可以使用ssh登陸Ubuntu了,所以是Ubuntu的基礎設定之一。
事前准備
Ubuntu版本:17.10
devops@ubuntu:~$ cat /etc/issue
Ubuntu 17.10
l
devops@ubuntu:~$
devops@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 17.10
Release: 17.10
Codename: artful
devops@ubuntu:~$
17.10的Ubuntu代號Artful Aardvark,於2017年10月19日正式發布,是更換GNOME的首個版本,但是這不是一個LTS版本,會支持到2018年8月,是2018年Ubuntu的LTS的版本之前的過渡版本。openssh-server的安裝基本上對於Ubuntu的版本影響非常低,基本操作步驟大體一致。
安裝步驟
按照如下安裝步驟進行安裝
步驟 | 命令 | 說明 |
---|
步驟1 | sudo su | 切換至root用戶,ubuntu缺省下root用戶有所限制,使用sudo su可以使用當前管理用戶的密碼切換至root用戶,也可以在需要安裝權限的命令前加sudo |
步驟2 | apt install openssh-server | 安裝openssh-server |
步驟3 | ssh -V | 確認openssh-server版本 |
步驟4 | /etc/init.d/ssh status | 確認openssh-server狀態 |
步驟5 | /etc/init.d/ssh restart | 重新啟動 openssh-server |
步驟6 | 從終端使用ssh命令連接確認 | |
操作日志
此處再以安裝的狀態下抓取的日志,apt install顯示會有所不同
devops@ubuntu:~$ sudo su
[sudo] password for devops:
root@ubuntu:/home/devops#
root@ubuntu:/home/devops# apt install openssh-server
Reading package lists Done
Building dependency tree
Reading state information Done
openssh-server is already the newest version (1:7.5p1-10ubuntu0.1).
0 upgraded, 0 newly installed, 0 to remove and 55 not upgraded.
root@ubuntu:/home/devops#
root@ubuntu:/home/devops# ssh -V
OpenSSH_7.5p1 Ubuntu-10ubuntu0.1, OpenSSL 1.0.2g 1 Mar 2016
root@ubuntu:/home/devops#
root@ubuntu:/home/devops# /etc/init.d/ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2018-03-03 07:58:44 CST; 51min ago
Process: 3072 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 3071 ExecReload=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Process: 3167 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 3179 (sshd)
Tasks: 1 (limit: 4915)
Memory: 1.0M
CPU: 7ms
CGroup: /system.slice/ssh.service
└─3179 /usr/sbin/sshd -D
Mar 03 07:58:44 ubuntu systemd[1]: Starting OpenBSD Secure Shell server
Mar 03 07:58:44 ubuntu systemd[1]: Started OpenBSD Secure Shell server.
Mar 03 07:58:44 ubuntu sshd[3179]: Server listening on 0.0.0.0 port 22.
Mar 03 07:58:44 ubuntu sshd[3179]: Server listening on :: port 22.
root@ubuntu:/home/devops#
root@ubuntu:/home/devops# /etc/init.d/ssh restart
[ ok ] Restarting ssh (via systemctl): ssh.service.
root@ubuntu:/home/devops#
從終端進行ssh連接
liumiaocn:~ liumiao$ ssh devops@192.168.31.19
devops@192.168.31.19's password:
Welcome to Ubuntu 17.10 (GNU/Linux 4.13.0-21-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
58 packages can be updated.
32 updates are security updates.
Last login: Sat Mar 3 07:43:23 2018 from 192.168.31.242
devops@ubuntu:~$