sudo /etc/init.d/ssh start
sudo /etc/init.d/ssh stop #server停止ssh服务
sudo /etc/init.d/ssh restart #server重启ssh服务
SSH分为客户端 openssh-client
和服务器 openssh-server
。
dpkg -l | grep ssh
# 输出
yichao@yichao:~$ dpkg -l | grep ssh
ii libssh-4:amd64 0.6.3-4.3ubuntu0.6 amd64 tiny C SSH library (OpenSSL flavor)
ii libssh-gcrypt-4:amd64 0.6.3-4.3ubuntu0.6 amd64 tiny C SSH library (gcrypt flavor)
ii libssh2-1:amd64 1.5.0-2ubuntu0.1 amd64 SSH2 client-side library
ii openssh-client 1:7.2p2-4ubuntu2.10 amd64 secure shell (SSH) client, for secure access to remote machines
ii openssh-server 1:7.2p2-4ubuntu2.10 amd64 secure shell (SSH) server, for secure access from remote machines
ii openssh-sftp-server 1:7.2p2-4ubuntu2.10 amd64 secure shell (SSH) sftp server module, for SFTP access from remote machines
ii ssh-import-id 5.5-0ubuntu1 all securely retrieve an SSH public key and install it locally
Ubuntu默认安装了openssh-client。
sudo apt-get install openssh-client
如果要开放本机的SSH服务就需要安装openssh-server。
sudo apt-get install openssh-server
ps -e | grep ssh
如果没有启动,可以使用如下命令启动:
sudo /etc/init.d/ssh start
ssh yichao@192.168.0.147
ssh yichao@192.168.0.147 -p 22
-p 指定服务器端口号,默认 22
yichao 为登录的用户名
192.168.0.147 为服务器ip,也可使用域名
openssh-server
ssh: connect to host 192.168.0.147 port 22: Connection refused
(base)
错误原因:
服务端未安装 openssh-server
解决办法:
服务端安装openssh-server
sudo apt-get install openssh-server