Ubuntu20.04换源、固定IP、连接Xshell

一、安装好新系统之后,先安装几个重要工具

进入终端,使用sudo su登录管理员进行操作

使用vim编辑,不要问为啥,vi真难用,55555.....
apt-get install vim

新系统无法用ifconfig查看网络
apt-get install net-tools

二、换源(这里用的是阿里云的源)

打开源文件目录
cd /etc/apt/

先备份一下原始源
cp source.list source.list.backup

修改源文件
vim  source.list

将里面所有内容删掉,删干净,是所有!!!
将下面内容复制进去并保存退出:
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal universe
deb http://mirrors.aliyun.com/ubuntu/ focal-updates universe
deb http://mirrors.aliyun.com/ubuntu/ focal multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-security universe
deb http://mirrors.aliyun.com/ubuntu/ focal-security multiverse

保存后,即可执行更新
apt update
apt upgrade

这里也提供清华源的地址:https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/

三、固定IP

使用ifconfig查看网卡和当前IP地址
ifconfig
可以看到网卡为ens33,IP地址为192.168.174.131

修改网络配置文件
cd /etc/netplan/
修改配置文件
vim 01-network-manager-all.yaml

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    ens33: #配置的网卡名称,使用ifconfig -a查看得到
      dhcp4: no #dhcp4关闭
      optional: true
      addresses: [192.168.174.100/24] #设置本机IP及掩码
      gateway4: 192.168.174.2 #设置网关
      nameservers:
        addresses: [192.168.174.2,8.8.8.8,114,114,114,114] #设置DNS

退出并保持后,重启网络服务
netplan apply

再使用ifconfig查看IP地址是否修改成功

四、连接Xshell

查看ssh服务,
ps -e|grep ssh

如果只出现ssh -agent,没有sshd就还需要安装openssh-server
apt-get install openssh-server
启动服务
service ssh start

再次输入ps -e|grep ssh查看服务,应该ssh -agent和sshd都有了

咋子就可以用Xshell连接了,使用用户名和密码登录

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值