如何在Ubuntu操作系统中开启SSH服务和设置IP_箱子_百度空间 (转载)

SSH设置:

1、默认ubuntu已经安装好了客户端
2、如使用命令:ps -e|grep ssh
3、会打印出来:ssh-agent
4、下面安装服务端:sudo apt-get install openssh-server
(sudo apt-get install ssh )
5、安装好后会自动启动服务,再使用命令ps -e|grep ssh
6、会打印出: ssh-agent 和sshd
7、现在可以在其它系统使用ssh工具连到这台电脑了。
8、在上面如果没有启动ssh命令则:sudo /etc/init.d/ssh start
9、etc/ssh/sshd_config里面可修改ssh端口,默认为22
10、重启ssh服务 sudo /etc/init.d/ssh restart
11,安装vsftpd
#sudo apt-get install vsftp
设置/etc/vsftpd.conf,由于不需要对外开放FTP,只是内网访问,相关设置如下.
#拒绝匿名用户,将其注释掉
#anonymous_enable=YES
#接受本地用户
local_enable=YES
#可以上传
write_enable=YES
#允许上传Ascii文件
ascii_upload_enable=YES
ascii_download_enable=YES
启动vsftpd
/etc/init.d vsftpd star

IP设置:
一、使用命令设置Ubuntu IP地址

1.修改配置文件blacklist.conf禁用IPV6:sudo vi /etc/modprobe.d/blacklist.conf

2.在文档最后添加 blacklist ipv6,然后查看修改结果:cat /etc/modprobe.d/blacklist.conf

3.设置Ubuntu IP(设置网卡eth0的IP地址和子网掩码)sudo ifconfig eth0 192.168.2.1 netmask 255.255.255.0

4.Ubuntu IP设置网关sudo route add default gw 192.168.2.254

5.Ubuntu IP设置DNS 修改/etc/resolv.conf,在其中加入nameserver DNS的地址1 和 nameserver DNS的地址2 完成。

6.重启网络服务(若不行,请重启ubuntu:sudo reboot):sudo /etc/init.d/networking restart

7.查看当前Ubuntu IP:ifconfig

二、直接修改Ubuntu IP系统配置文件

Ubuntu IP的网络配置文件是:/etc/network/interfaces打开后里面可设置DHCP或手动设置静态ip。前面auto eth0,让网卡开机自动挂载。

1. 以DHCP方式配置网卡


编辑文件/etc/network/interfaces:
sudo vi /etc/network/interfaces

并用下面的行来替换有关eth0的行:


# The primary network interface - use DHCP to find our address
auto eth0
iface eth0 inet dhcp

用下面的命令使网络设置生效:


sudo /etc/init.d/networking restart

也可以在命令行下直接输入下面的命令来获取地址sudo dhclient eth0

2. 为网卡配置静态Ubuntu IP地址


编辑文件/etc/network/interfaces:
sudo vi /etc/network/interfaces

并用下面的行来替换有关eth0的行:


# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.2.1
gateway 192.168.2.254
netmask 255.255.255.0
#network 192.168.2.0
#broadcast 192.168.2.255

将上面的Ubuntu IP地址等信息换成你自己就可以了.用下面的命令使网络设置生效:


sudo /etc/init.d/networking restart

3. 设定第二个Ubuntu IP地址(虚拟IP地址)


编辑文件/etc/network/interfaces:
sudo vi /etc/network/interfaces

在该文件中添加如下的行:


auto eth0:1
iface eth0:1 inet static
address x.x.x.x
netmask x.x.x.x
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x

根据你的情况填上所有诸如address,netmask,network,broadcast和gateways等信息:用下面的命令使网络设置生效:sudo /etc/init.d/networking restart

4. 设置主机名称(hostname)
使用下面的命令来查看当前主机的主机名称:sudo /bin/hostname
使用下面的命令来设置当前主机的主机名称:sudo /bin/hostname newname
系统启动时,它会从/etc/hostname来读取主机的名称。

5. 配置DNS

首先,你可以在/etc/hosts中加入一些主机名称和这些主机名称对应的IP地址,这是简单使用本机的静态查询。要访问DNS 服务器来进行查询,需要设置/etc/resolv.conf文件,假设DNS服务器的IP地址是192.168.2.2, 那么/etc/resolv.conf文件的内容应为:
search chotim.com
nameserver 192.168.2.2

6.手动重启网络服务:sudo /etc/init.d/networking restart



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Ubuntu操作系统安装完成后网络管理默认是用DHCP自动获取IP地址的,之前在自己住宿就一两台机使用反正也没啥差就懒得改为静态固定IP,但是最近在公司使用vm虚拟机下安装了台Ubuntu8.10玩一玩,有时基本使用SecureCRT软件SSH远程登陆使用,但是由于公司使用都是内部动态 IP地址,而且机器较多所以导致IP地址经常性更换,有点烦所以自己决定试图修改成使用静态IP,可是那个可恶的NetworkManager总是在重启后又变成默认的DHCP自动获取IP。。。故决定删除彻底NetworkManager

sudo apt-get –purge remove network-manager
sudo apt-get –purge remove network-manager-gnome
手动设置静态IP地址:编辑修改网络接口配置文件/etc/network/interfaces

sudo vim /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 172.17.4.170
netmask 255.255.255.0
network 172.17.4.1
gateway 172.17.4.3
修改设置DNS服务器配置文件/etc/resolv.conf

sudo vim /etc/resolv.conf
nameserver 202.101.103.54
nameserver 202.101.103.55
nameserver 172.17.4.1
最后重启网络服务

sudo /etc/init.d/networking restart
这样上网基本就没什么问题啦/// 如果你之前没有删除NetworkManager网络管理的话,重启后/etc/resolv.conf里面的配置文件又会被修改为

# Generated by NetworkManager
导致又是使用DHCP动态分配IP地址的。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值