使用VMware安装了ubuntu server做做docker练习,但发现在虚拟机内操作很不方便,因为焦点是在虚拟机上,无法使用快捷键快速切回window上,所以就想着弄个ssh登录好了。简单记录下
首先确定IP
1、 ubuntu内输入命令确认ip: ifconfig
ens33Link encap:Ethernet HWaddr 00:0c:29:4b:c8:cc
inet addr:192.168.206.128 Bcast:192.168.206.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe4b:c8cc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:49206 errors:0 dropped:0 overruns:0frame :0
TX packets:21539 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:62660533 (62.6 MB) TX bytes:1352090 (1.3 MB)
loLink encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:169 errors:0 dropped:0 overruns:0frame :0
TX packets:169 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:12369 (12.3 KB) TX bytes:12369 (12.3 KB)
以上 192.168.206.128
就是虚拟机ip
2、 windows使用命令ping下ip试试通不通: ping 192.168.206.128
正常应该没问题:
C:\Users\ozhu2>ping 192.168.206.128
正在 Ping 192.168.206.128 具有 32 字节的数据:
来自 192.168.206.128 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.206.128 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.206.128 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.206.128 的回复: 字节=32 时间<1ms TTL=64
192.168.206.128 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 0ms,平均 = 0ms
安装SSH服务
1、 ubuntu内输入命令确认是否安装ssh: ssh localhost
如果出现下面提示则表示还没有安装:
ssh: connect to hostlocalhost port 22: Connection refused
2、安装ssh服务: sudo apt-get install openssh-server
3、安装完毕输入命令查看状态: sudo service ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2016-10-09 06:59:39 PDT; 28min ago
Main PID: 18710 (sshd)
CGroup: /system.slice/ssh.service
└─18710 /usr/sbin/sshd -D
Oct 09 06:59:39 ubuntu sshd[18710]: Server listening on 0.0.0.0 port 22.
Oct 09 06:59:39 ubuntu sshd[18710]: Server listening on :: port 22.
Oct 09 06:59:39 ubuntu systemd[1]: Started OpenBSD Secure Shell server.
Oct 09 07:00:24 ubuntu sshd[18726]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.206.1 user=root
Oct 09 07:00:25 ubuntu sshd[18726]: Failed password for root from 192.168.206.1 port 62982 ssh2
Oct 09 07:00:35 ubuntu sshd[18726]: Failed password for root from 192.168.206.1 port 62982 ssh2
Oct 09 07:00:54 ubuntu sshd[18726]: Failed password for root from 192.168.206.1 port 62982 ssh2
Oct 09 07:01:05 ubuntu sshd[18726]: Failed password for root from 192.168.206.1 port 62982 ssh2
Oct 09 07:07:22 ubuntu sshd[18753]: Accepted password for hucw from 192.168.206.1 port 64950 ssh2
Oct 09 07:07:22 ubuntu sshd[18753]: pam_unix(sshd:session): session opened for user hucw by (uid=0)
4、使用ssh工具连接吧,我使用的是xshell 5