ubuntu16.04 ssh

前提:

1.用网线连接开发板,开发板运行linux,桥接有线网卡,static
2.可以用windows ping 通 192.168.0.109(我的static 的地址)
3.可以用secureCRT登陆上192.168.0.109

SSH安装:

VMware的编辑tab->虚拟网络编辑 菜单查看网络配置:

子网IP:192.168.0.109
子网掩码:255.255.255.0
网关IP:192.168.0.1

1.进入su模式下,vi /etc/network/interfaces设置虚拟机IP为static的,

2.设置DNS服务器的信息,vi /etc/resolv.conf

这里写图片描述

nameserver 180.76.76.76   百度DNS
nameserver 223.5.5.5      阿里DNS
nameserver 192.168.92.1   网关地址

3.配置网关地址route add default gw 192.168.0.1

4.重新启动网络服务,命令:

/etc/init.d/networking reload
sudo /etc/init.d/networking restart

5.重启ubuntu

6.网络OK了,然而不能从远程SSH连接到主机

ps -e|grep ssh发现没有sshd服务
执行:
apt-get install openssh-sever
正在读取软件包列表...
完成正在分析软件包的依赖关系树正在读取状态信息...
完成现在没有可用的软件包 openssh-server,
但是他被其他的软件包引用了这可能意味着这个缺失的软件包可能已被废弃,或者只能在其他发布源中找到
E:软件包 openssh-server 还没有可供安装的候选者

解决方案:apt-get没有更新,执行

这里写图片描述
7.更新完毕后执行安装:

apt-get install openssh-server
这里写图片描述
8.启动ssh服务:
/etc/init.d/ssh start
netstat -tlp
这里写图片描述
也可以通过ps -e|grep ssh来看下open-server安装是否成功,
这里写图片描述

9.修改ssh配置,vi /etc/ssh/sshd_config

这里写图片描述

10.使用secureCRT客户端连接192.168.0.109虚拟机,连接OK。

如果还是登陆不上SSH:

SSH Secure Shell Client 连接VMware ubuntu系统报错

修改ssh的配置文件 /etc/ssh/sshd_config

在配置文件中添加:

Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc

MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96

KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org

重启sshd服务后,即可正常连接。

sudo service ssh restart

另外重启方式还有  sudo /etc/init.d/ssh restart

VM虚拟机下面编辑选项中有粘贴操作。

参考文章:
https://www.linuxidc.com/Linux/2017-12/149931.htm
http://blog.csdn.net/lifeifei2010/article/details/50922374
http://www.cnblogs.com/mliudong/p/4094519.html

猜你喜欢

转载自blog.csdn.net/m0_37182543/article/details/79435260