
正文
Xshell5 访问虚拟机Ubuntu16.04
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
1.Ubuntu安装telnet
安装openbsd-inetd
sudo apt-get install openbsd-inetd安装telnetd
sudo apt-get install telnetd重启openbsd-inetd
sudo /etc/init.d/openbsd-inetd restart查看telnet运行状态
sudo netstat -a | grep telnet登录
telnet IP address
访问:
hongdada@ubuntu:~$ telnet 192.168.1.203 22
Trying 192.168.1.203...
telnet: Unable to connect to remote host: Connection refused
使用 netstat -napt查看端口是否被监听
hongdada@ubuntu:~$ netstat -napt
(并非所有进程都能被检测到,所有非本用户的进程信息将不会显示,如果想看到所有信息,则必须切换到 root 用户)
激活Internet连接 (服务器和已建立连接的)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN -
tcp 0 0 192.168.1.203:44850 124.192.164.34:80 ESTABLISHED 5200/chrome
tcp 0 0 192.168.1.203:39874 119.75.213.61:443 ESTABLISHED
发现22并没有被监听
安装OpenSSH
hongdada@ubuntu:~$ sudo apt-get install openssh-server
[sudo] hongdada 的密码:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
linux-headers-4.4.- linux-headers-4.4.--generic linux-headers-4.4.-
linux-headers-4.4.--generic linux-headers-4.4.-
linux-headers-4.4.--generic linux-headers-4.4.-
linux-headers-4.4.--generic linux-headers-4.4.-
linux-headers-4.4.--generic linux-image-4.4.--generic
linux-image-4.4.--generic linux-image-4.4.--generic
linux-image-4.4.--generic linux-image-4.4.--generic
linux-image-extra-4.4.--generic linux-image-extra-4.4.--generic
linux-image-extra-4.4.--generic linux-image-extra-4.4.--generic
linux-image-extra-4.4.--generic
使用'sudo apt autoremove'来卸载它(它们)。
将会同时安装下列软件:
ncurses-term openssh-client openssh-sftp-server ssh-import-id
建议安装:
ssh-askpass libpam-ssh keychain monkeysphere rssh molly-guard
下列【新】软件包将被安装:
ncurses-term openssh-server openssh-sftp-server ssh-import-id
下列软件包将被升级:
openssh-client
升级了 个软件包,新安装了 个软件包,要卸载 个软件包,有 个软件包未被升级。
需要下载 , kB 的归档。
解压缩后会消耗 , kB 的额外空间。
您希望继续执行吗? [Y/n] Y
获取: http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 openssh-client amd64 1:7.2p2-4ubuntu2.2 [587 kB]
获取: http://mirrors.aliyun.com/ubuntu xenial/main amd64 ncurses-term all 6.0+20160213-1ubuntu1 [249 kB]
获取: http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 openssh-sftp-server amd64 1:7.2p2-4ubuntu2.2 [38.7 kB]
获取: http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 openssh-server amd64 1:7.2p2-4ubuntu2.2 [338 kB]
获取: http://mirrors.aliyun.com/ubuntu xenial/main amd64 ssh-import-id all 5.5-0ubuntu1 [10.2 kB]
已下载 , kB,耗时 1秒 (, kB/s)
正在预设定软件包 ...
(正在读取数据库 ... 系统当前共安装有 个文件和目录。)
正准备解包 .../openssh-client_1%3a7.2p2-4ubuntu2.2_amd64.deb ...
正在将 openssh-client (:.2p2-4ubuntu2.) 解包到 (:.2p2-4ubuntu2.) 上 ...
正在选中未选择的软件包 ncurses-term。
正准备解包 .../ncurses-term_6.+-1ubuntu1_all.deb ...
正在解包 ncurses-term (6.0+-1ubuntu1) ...
正在选中未选择的软件包 openssh-sftp-server。
正准备解包 .../openssh-sftp-server_1%3a7.2p2-4ubuntu2.2_amd64.deb ...
正在解包 openssh-sftp-server (:.2p2-4ubuntu2.) ...
正在选中未选择的软件包 openssh-server。
正准备解包 .../openssh-server_1%3a7.2p2-4ubuntu2.2_amd64.deb ...
正在解包 openssh-server (:.2p2-4ubuntu2.) ...
正在选中未选择的软件包 ssh-import-id。
正准备解包 .../ssh-import-id_5.-0ubuntu1_all.deb ...
正在解包 ssh-import-id (5.5-0ubuntu1) ...
正在处理用于 man-db (2.7.-) 的触发器 ...
正在处理用于 ufw (0.35-0ubuntu2) 的触发器 ...
正在处理用于 systemd (-4ubuntu16) 的触发器 ...
正在处理用于 ureadahead (0.100.-) 的触发器 ...
正在设置 openssh-client (:.2p2-4ubuntu2.) ...
正在设置 ncurses-term (6.0+-1ubuntu1) ...
正在设置 openssh-sftp-server (:.2p2-4ubuntu2.) ...
正在设置 openssh-server (:.2p2-4ubuntu2.) ...
Creating SSH2 RSA key; this may take some time ...
SHA256:Fggzi+si7eAimez/6obJ9ykFiTnBvfOkQk1D3G198KI root@ubuntu (RSA)
Creating SSH2 DSA key; this may take some time ...
SHA256:l1qkn+YwdNyBnNVurPG2Qg22CrVL/41VAyqqZr6I1Lc root@ubuntu (DSA)
Creating SSH2 ECDSA key; this may take some time ...
SHA256:QCmE/BZXVtoThmb0gmxbRD7+vzTX+cbVud6e9EXW2cE root@ubuntu (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
SHA256:1D0iLpOURGJF4sMTzCoittU3V27FyXO72hr/HFJtO2U root@ubuntu (ED25519)
正在设置 ssh-import-id (5.5-0ubuntu1) ...
正在处理用于 systemd (-4ubuntu16) 的触发器 ...
正在处理用于 ureadahead (0.100.-) 的触发器 ...
正在处理用于 ufw (0.35-0ubuntu2) 的触发器 ...
hongdada@ubuntu:~$ ps -e|grep ssh
? :: sshd
hongdada@ubuntu:~$ netstat -antp|grep
(并非所有进程都能被检测到,所有非本用户的进程信息将不会显示,如果想看到所有信息,则必须切换到 root 用户)
tcp 0.0.0.0: 0.0.0.0:* LISTEN -
tcp 192.168.1.203: 23.219.133.226: CLOSE_WAIT /chrome
tcp 192.168.1.203: 117.122.217.6: CLOSE_WAIT /chrome
tcp 192.168.1.203: 117.122.217.6: CLOSE_WAIT /chrome
tcp 192.168.1.203: 180.76.22.33: CLOSE_WAIT /chrome
tcp 192.168.1.203: 124.192.164.48: CLOSE_WAIT /chrome
tcp 192.168.1.203: 180.76.22.33: CLOSE_WAIT /chrome
tcp 192.168.1.203: 115.28.122.210: TIME_WAIT -
tcp 192.168.1.203: 180.76.22.33: CLOSE_WAIT /chrome
tcp 192.168.1.203: 23.219.133.226: CLOSE_WAIT /chrome
tcp 192.168.1.203: 117.122.217.6: CLOSE_WAIT /chrome
tcp 192.168.1.203: 117.122.217.6: CLOSE_WAIT /chrome
tcp 192.168.1.203: 180.76.22.33: CLOSE_WAIT /chrome
tcp 192.168.1.203: 13.124.96.226: CLOSE_WAIT /chrome
tcp 192.168.1.203: 23.219.133.226: CLOSE_WAIT /chrome
tcp 192.168.1.203: 180.76.22.33: CLOSE_WAIT /chrome
tcp 192.168.1.203: 180.76.22.33: CLOSE_WAIT /chrome
tcp 192.168.1.203: 119.75.222.191: CLOSE_WAIT /chrome
tcp 192.168.1.203: 52.221.26.127: CLOSE_WAIT /chrome
tcp 192.168.1.203: 59.110.88.38: CLOSE_WAIT /chrome
tcp 192.168.1.203: 119.75.222.22: FIN_WAIT1 -
tcp 192.168.1.203: 117.122.217.6: CLOSE_WAIT /chrome
tcp 192.168.1.203: 13.124.96.226: CLOSE_WAIT /chrome
tcp 192.168.1.203: 119.75.222.22: CLOSE_WAIT /chrome
tcp 192.168.1.203: 117.122.217.6: CLOSE_WAIT /chrome
tcp 192.168.1.203: 180.76.22.33: CLOSE_WAIT /chrome
tcp 192.168.1.203: 119.75.222.22: CLOSE_WAIT /chrome
tcp 192.168.1.203: 180.76.22.33: CLOSE_WAIT /chrome
tcp 192.168.1.203: 13.124.96.226: CLOSE_WAIT /chrome
tcp 192.168.1.203: 124.14.17.221: CLOSE_WAIT /chrome
tcp 192.168.1.203: 23.219.133.226: ESTABLISHED /chrome
tcp 192.168.1.203: 119.75.222.191: FIN_WAIT1 -
tcp 192.168.1.203: 180.76.22.33: CLOSE_WAIT /chrome
tcp 192.168.1.203: 180.76.22.33: CLOSE_WAIT /chrome
tcp 192.168.1.203: 23.219.133.226: CLOSE_WAIT /chrome
tcp 192.168.1.203: 180.76.22.33: CLOSE_WAIT /chrome
tcp 192.168.1.203: 13.124.96.226: CLOSE_WAIT /chrome
tcp 192.168.1.203: 203.208.43.90: ESTABLISHED /chrome
tcp 192.168.1.203: 203.208.43.90: ESTABLISHED /chrome
tcp 192.168.1.203: 52.221.26.127: CLOSE_WAIT /chrome
tcp6 ::: :::* LISTEN -
hongdada@ubuntu:~$ telnet 127.0.0.1
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.Protocol mismatch.
Connection closed by foreign host.
hongdada@ubuntu:~$
Ubuntu 默认安装了client端,但是没有安装Server端,所以现在要安装openssh-server
sudo apt-get install openssh-server
安装以后查看22端口是否被监听
netstat -antp|grep 22
如果只有ssh-agent那ssh-server还没有启动,需要/etc/init.d/ssh start或者service ssh start,如果看到sshd那说明ssh-server已经启动了。
ssh-server配置文件位于/ etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。然后重启SSH服务:
sudo /etc/init.d/ssh restart
现在使用xshell访问Ubuntu


连接:
Xshell 5 (Build 1124)
Copyright (c) 2002-2017 NetSarang Computer, Inc. All rights reserved.Type `help' to learn how to use Xshell prompt.
[c:\~]$ Connecting to 192.168.1.203:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-83-generic x86_64) * Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage140 个可升级软件包。
0 个安全更新。Last login: Tue Jul 18 23:51:42 2017 from 192.168.1.222
hongdada@ubuntu:~$
http://www.linuxidc.com/Linux/2014-02/97218.htm







