window用ssh连接本机虚拟机中的ubuntu
来自:http://www.cnblogs.com/linjiqin/p/3148337.html window用ssh连接本机虚拟机中的ubuntu主机和虚拟机间通信,需将2台机器的IP地址设为同一网段。1、设置虚拟机: 虚拟机–> 设置–> Hardware –> Network Adapter,在网络连接处设置为 “桥接:直接连接到物理网络”,“NAT:使用已共享的主
来自:
http://www.cnblogs.com/linjiqin/p/3148337.html
window用ssh连接本机虚拟机中的ubuntu
主机和虚拟机间通信,需将2台机器的IP地址设为同一网段。
1、设置虚拟机: 虚拟机–> 设置–> Hardware –> Network Adapter,在网络连接处设置为 “桥接:直接连接到物理网络”,“NAT:使用已共享的主机IP地址”处打勾。
2、window和虚拟机下ubuntu的IP地址设为同一网段
Ubuntu配置和修改IP地址请看:http://www.tieguanyin168.com/index.php/ubuntu-ip-1641.html
其实在第一步中,哪一步中设为桥接模式,并勾选下面那个复选框,就是同一个网段
采用桥接设置才可以PING 通网关
最好设置个静态IP:
sudo vi /etc/network/interfaces,将原有动态IP屏蔽掉
并用下面的行来替换有关eth0的行:在# The primary network interface之后,或在末尾加上
auto eth0
iface eth0 inet static
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.255
将上面的ip地址等信息换成你自己就可以了.用下面的命令使网络设置生效:
sudo /etc/init.d/networking restart
3、互ping下,判断windows与linux是否互相ping通。
i、C:\Users\jiqinlin>ping 192.168.11.88 #192.168.11.88虚拟机下ubuntu的ip
正在 Ping 192.168.11.88 具有 32 字节的数据:
来自 192.168.11.88 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.11.88 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.11.88 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.11.88 的回复: 字节=32 时间<1ms TTL=64
192.168.11.88 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 0ms,平均 = 0ms
ii、root@ubuntu:~# ping 192.168.11.74 #192.168.11.74 windows下ip
PING 192.168.11.74 (192.168.11.74) 56(84) bytes of data.
64 bytes from 192.168.11.74: icmp_req=1 ttl=64 time=0.242 ms
64 bytes from 192.168.11.74: icmp_req=2 ttl=64 time=0.268 ms
64 bytes from 192.168.11.74: icmp_req=3 ttl=64 time=0.251 ms
出现类似信息表示windows与linux已互通。
4、连接ssh,在连接前记得在window下安装SSH Secure Shell Client客户端
操作步骤如下:
在win7下通过ssh连接虚拟机的ubuntu,连接失败,提示信息见下图:
然后我在ubuntu终端下输入:ssh localhost,见下图:
ssh : connect to host localhost port 22: Connection refused,原来没有装sshd,也就是openssh-server。
输入命令: sudo apt-get install openssh-server
也可能会出现:Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
再:apt-get update
然后输入命令:ssh localhost,见下图
此时可以通过ssh工具连虚拟机的ubuntu系统了。
vmware虚拟机上ubuntu 10.04不能连上外网解决办法
:http://blog.csdn.net/lys07962000/article/details/26173055
ubuntu apt-get update 失败解决。
http://blog.csdn.net/ronghua_liu/article/details/8609450
当运行apt-get update后出现如下错误时:
E: Some index files failed to download, they have been ignored, or old ones used instead.
可以将目录下/var/lib/apt/lists/partial/所有的文件清掉,再次运行apt-get update即可!自带源在大陆不好。
出现以下错误:
- /etc/apt$ sudo apt-get update
- Err http://security.ubuntu.com precise-security InRelease
- Err http://security.ubuntu.com precise-security Release.gpg
- Temporary failure resolving 'security.ubuntu.com'
- Err http://cn.archive.ubuntu.com precise InRelease
- Err http://cn.archive.ubuntu.com precise-updates InRelease
- Err http://cn.archive.ubuntu.com precise-backports InRelease
- Err http://cn.archive.ubuntu.com precise Release.gpg
- Temporary failure resolving 'cn.archive.ubuntu.com'
- Err http://cn.archive.ubuntu.com precise-updates Release.gpg
- Temporary failure resolving 'cn.archive.ubuntu.com'
- Err http://cn.archive.ubuntu.com precise-backports Release.gpg
- Temporary failure resolving 'cn.archive.ubuntu.com'
- Reading package lists... Done
- W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise/InRelease
- W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease
- W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-backports/InRelease
- W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease
- W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg Temporary failure resolving 'security.ubuntu.com'
- W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving 'cn.archive.ubuntu.com'
- W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-updates/Release.gpg Temporary failure resolving 'cn.archive.ubuntu.com'
- W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-backports/Release.gpg Temporary failure resolving 'cn.archive.ubuntu.com'
- W: Some index files failed to download. They have been ignored, or old ones used instead.
- xinju@xinjuOffice:/etc/apt$ cd ../network
/etc/apt$ sudo apt-get update
Err http://security.ubuntu.com precise-security InRelease
Err http://security.ubuntu.com precise-security Release.gpg
Temporary failure resolving 'security.ubuntu.com'
Err http://cn.archive.ubuntu.com precise InRelease
Err http://cn.archive.ubuntu.com precise-updates InRelease
Err http://cn.archive.ubuntu.com precise-backports InRelease
Err http://cn.archive.ubuntu.com precise Release.gpg
Temporary failure resolving 'cn.archive.ubuntu.com'
Err http://cn.archive.ubuntu.com precise-updates Release.gpg
Temporary failure resolving 'cn.archive.ubuntu.com'
Err http://cn.archive.ubuntu.com precise-backports Release.gpg
Temporary failure resolving 'cn.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise/InRelease
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-backports/InRelease
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg Temporary failure resolving 'security.ubuntu.com'
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving 'cn.archive.ubuntu.com'
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-updates/Release.gpg Temporary failure resolving 'cn.archive.ubuntu.com'
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-backports/Release.gpg Temporary failure resolving 'cn.archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
xinju@xinjuOffice:/etc/apt$ cd ../network
阿里源:
- deb http://mirrors.aliyun.com/ubuntu/ raring main restricted universe multiverse
- deb http://mirrors.aliyun.com/ubuntu/ raring-security main restricted universe multiverse
- deb http://mirrors.aliyun.com/ubuntu/ raring-updates main restricted universe multiverse
- deb http://mirrors.aliyun.com/ubuntu/ raring-proposed main restricted universe multiverse
- deb http://mirrors.aliyun.com/ubuntu/ raring-backports main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ raring main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ raring-security main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ raring-updates main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ raring-proposed main restricted universe multiverse
- deb-src http://mirrors.aliyun.com/ubuntu/ raring-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ raring main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ raring-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ raring-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ raring-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ raring-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ raring main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ raring-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ raring-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ raring-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ raring-backports main restricted universe multiverse
修改ip:
- # This file describes the network interfaces available on your system
- # and how to activate them. For more information, see interfaces(5).
- # The loopback network interface
- auto lo
- iface lo inet loopback
- # The primary network interfacea
- auto eth0
- iface eth0 inet static
- address 192.168.2.170
- netmask 255.255.255.0
- broadcast 192.168.2.255
- gateway 192.168.2.1
- dns-nameservers 192.168.2.1
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interfacea
auto eth0
iface eth0 inet static
address 192.168.2.170
netmask 255.255.255.0
broadcast 192.168.2.255
gateway 192.168.2.1
dns-nameservers 192.168.2.1
修改dns:
1,重启生效:
sudo vi /etc/resolvconf/resolv.conf.d/base(这个文件默认是空的)
在里面插入:
nameserver 8.8.8.8
nameserver 8.8.4.4
如果有多个DNS就一行一个
修改好保存,然后执行
sudo resolvconf -u
再看/etc/resolv.conf,最下面就多了2行:
cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4
可以看到我们的设置已经加上了,然后再ping一个域名,当时就可以解析了,无需重启。
2,重启失效:
配置文件地址 /etc/resolv.conf
使用编辑器打开
改为如下内容:
search localdomain
nameserver 202.96.128.86 希望修改成的DNS
nameserver 202.96.128.166 备用DNS
重启网络:sudo /etc/init.d/networking restart。即可
在目录:/var/lib/apt/lists/partial 输入:
/etc/init.d/networking restart
提示:sh:0 :getcwd() failed: NO such file or directory//出现这个问题是该目录已经被删除
.....
cd / 之后 /etc/init.d/networking restart 就没上面哪个问题
更多推荐
所有评论(0)