Ubuntu 开启ssh 连接,设置静态 ip 地址。

工作需要进行远程计算机连接,这里采用ssh连接方式,系统为 Ubuntu 16.04 。仅记备忘。

安装ssh

ubuntu16.04默认没有安装ssh,需要安装:


1、sudo apt-get install openssh-server //安装命令
2、ps -ef|grep ssh                            //查看启动ssh没有
3、重启SSH服务:
sudo /etc/init.d/ssh stop
sudo /etc/init.d/ssh start
4、客户端命令行登陆:ssh username@192.168.1.112 
5、ssh配置文件位于/ etc/ssh/sshd_config,默认端口是22,你可以自己定义成其他端口号;

 

设置静态 ip,

参考一下两篇博客的方式

1.  http://blog.csdn.net/xiaohuozi_2016/article/details/54743992

2. https://www.cnblogs.com/lcword/p/5917412.html

这里我采用的是第一种方式设置,第二种貌似没有权限建立新文件,也没有对应的文件夹。

设置的方式是:

1、vi /etc/network/interfaces

添加内容:

auto eth0
iface eth0 inet static
address 192.168.8.100    
netmask 255.255.255.0
gateway 192.168.8.2
dns-nameserver 119.29.29.29

 

dns-nameserver 119.29.29.29这句一定需要有,

因为以前是DHCP解析,所以会自动分配DNS 服务器地址。

而一旦设置为静态IP后就没有自动获取到DNS服务器了,需要自己设置一个

设置完重启电脑后,/etc/resolv.conf 文件中会自动添加 nameserver 119.29.29.29

 

2、重启网络:sudo /etc/init.d/networking restart

注意 Ubuntu16.04中的网卡名称不是eth0。

重启电脑就可以了,

 

3. 还需要再路由器中相应的设置网络,参考这篇帖子:

  https://zhidao.baidu.com/question/537983585.html

 

posted @ 2018-02-27 20:50  cofludy  阅读(644)  评论(0编辑  收藏  举报