一、root 帐号开启 SSH 登录
Ubuntu默认不开启root账户是一种保护机制,尤其保护小白用户。在非root账户里,至少你用sudo激情删库之前,系统还要你输个密码冷静一下;如果登入了root账户,删系统关键文件的前后,可能得不到任何提示,系统当即崩溃(或者重启崩溃)是很危险的事情。所以root账户能不开就不开,强烈推荐等你对系统有充分了解并且熟知各项命令之后再开。
Ubuntu默认是没有开启root账户登录选项的,想要在启动系统时用root账户登录系统,需要自己进行额外的设置。
<span class="token function">sudo</span> <span class="token function">passwd</span> root<span class="token function">sudo</span> <span class="token function">passwd</span> rootsudo passwd root
执行命令后,首先输入当前账户密码,确认无误后,系统会提示Enter new UNIX password,这是root密码,自行设置。注意在Ubuntu的命令行中,输入的密码是不可见的,只需要输入之后回车即可。
<span class="token function">sudo</span> <span class="token function">vim</span> /etc/ssh/sshd_config<span class="token function">sudo</span> <span class="token function">vim</span> /etc/ssh/sshd_configsudo vim /etc/ssh/sshd_config
将PermitRootLogin prohibit-password
更改为:
PermitRootLogin yes
重启ssh服务:
<span class="token function">sudo</span> systemctl restart sshd<span class="token function">sudo</span> systemctl restart sshdsudo systemctl restart sshd
再次进行远程登录,即可成功:
修改server端的etc/ssh/sshd_config
<span class="token function">vi</span> /etc/ssh/sshd_config<span class="token function">vi</span> /etc/ssh/sshd_configvi /etc/ssh/sshd_config
ClientAliveInterval <span class="token number">60</span> #server每隔60秒发送一次请求给client,然后client响应,从而保持连接 ClientAliveCountMax <span class="token number">30</span> #server发出请求后,客户端没有响应得次数达到30,就自动断开连接,正常情况下,client不会不响应 TCPKeepAlive <span class="token function">yes</span>ClientAliveInterval <span class="token number">60</span> #server每隔60秒发送一次请求给client,然后client响应,从而保持连接 ClientAliveCountMax <span class="token number">30</span> #server发出请求后,客户端没有响应得次数达到30,就自动断开连接,正常情况下,client不会不响应 TCPKeepAlive <span class="token function">yes</span>ClientAliveInterval 60 #server每隔60秒发送一次请求给client,然后client响应,从而保持连接 ClientAliveCountMax 30 #server发出请求后,客户端没有响应得次数达到30,就自动断开连接,正常情况下,client不会不响应 TCPKeepAlive yes
这 样,SSH Server 每 60 秒就会自动发送一个信号给 Client,而等待 Client 回应,(注意:是服务器发心跳信号,不是客户端),如果客户端没有回应,会记录下来直到记录数超过 ClientAliveCountMax 的值时,才会断开连接。
systemctl reload sshdsystemctl reload sshdsystemctl reload sshd
如果你没有服务器端管理权限, 在客户端进行设置也可以实现
只要在/etc/ssh/ssh_config文件里加两个参数就行了
<span class="token function">vi</span> /etc/ssh/ssh_config<span class="token function">vi</span> /etc/ssh/ssh_configvi /etc/ssh/ssh_config
TCPKeepAlive <span class="token function">yes</span> ServerAliveInterval <span class="token number">300</span>TCPKeepAlive <span class="token function">yes</span> ServerAliveInterval <span class="token number">300</span>TCPKeepAlive yes ServerAliveInterval 300
前一个参数是说要保持连接,后一个参数表示每过5分钟发一个数据包到服务器表示“我还活着”
如果你没有root权限,修改或者创建 ~/.ssh/ssh_config也是可以的。
<span class="token function">vi</span> ~/.ssh/ssh_config<span class="token function">vi</span> ~/.ssh/ssh_configvi ~/.ssh/ssh_config
在这种方法中, 如果你只想针对某一个ssh连接进行持续, 你也可以直接在连接命令中进行设定
<span class="token function">ssh</span> <span class="token parameter variable">-o</span> <span class="token assign-left variable">TCPKeepAlive</span><span class="token operator">=</span>yes <span class="token parameter variable">-o</span> <span class="token assign-left variable">ServerAliveInterval</span><span class="token operator">=</span><span class="token number">300</span> root@139.198.178.237<span class="token function">ssh</span> <span class="token parameter variable">-o</span> <span class="token assign-left variable">TCPKeepAlive</span><span class="token operator">=</span>yes <span class="token parameter variable">-o</span> <span class="token assign-left variable">ServerAliveInterval</span><span class="token operator">=</span><span class="token number">300</span> root@139.198.178.237ssh -o TCPKeepAlive=yes -o ServerAliveInterval=300 root@139.198.178.237
二、ubuntu 20.04 设置静态ip
先确认你要修改的网卡号
<span class="token function">ip</span> addr<span class="token function">ip</span> addrip addr
Ubuntu20配置值静态ip时需要修改/etc/netplan下面
<span class="token function">sudo</span> <span class="token function">vim</span> /etc/netplan/00-installer-config.yaml<span class="token function">sudo</span> <span class="token function">vim</span> /etc/netplan/00-installer-config.yamlsudo vim /etc/netplan/00-installer-config.yaml
<span class="token key atrule">network</span><span class="token punctuation">:</span> <span class="token key atrule">ethernets</span><span class="token punctuation">:</span> <span class="token key atrule">enp0s3</span><span class="token punctuation">:</span> <span class="token key atrule">dhcp4</span><span class="token punctuation">:</span> <span class="token boolean important">false</span> <span class="token key atrule">addresses</span><span class="token punctuation">:</span> <span class="token punctuation">-</span> 192.168.5.171/24 <span class="token key atrule">gateway4</span><span class="token punctuation">:</span> 192.168.5.1 <span class="token key atrule">nameservers</span><span class="token punctuation">:</span> <span class="token key atrule">addresses</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>202.96.128.166<span class="token punctuation">,</span>223.5.5.5<span class="token punctuation">]</span> <span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token number">2</span><span class="token key atrule">network</span><span class="token punctuation">:</span> <span class="token key atrule">ethernets</span><span class="token punctuation">:</span> <span class="token key atrule">enp0s3</span><span class="token punctuation">:</span> <span class="token key atrule">dhcp4</span><span class="token punctuation">:</span> <span class="token boolean important">false</span> <span class="token key atrule">addresses</span><span class="token punctuation">:</span> <span class="token punctuation">-</span> 192.168.5.171/24 <span class="token key atrule">gateway4</span><span class="token punctuation">:</span> 192.168.5.1 <span class="token key atrule">nameservers</span><span class="token punctuation">:</span> <span class="token key atrule">addresses</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>202.96.128.166<span class="token punctuation">,</span>223.5.5.5<span class="token punctuation">]</span> <span class="token key atrule">version</span><span class="token punctuation">:</span> <span class="token number">2</span>network: ethernets: enp0s3: dhcp4: false addresses: - 192.168.5.171/24 gateway4: 192.168.5.1 nameservers: addresses: [202.96.128.166,223.5.5.5] version: 2
使用ip生效
<span class="token function">sudo</span> netplan apply <span class="token function">ip</span> addr<span class="token function">sudo</span> netplan apply <span class="token function">ip</span> addrsudo netplan apply ip addr
如果应用么有生效,我们可以通过命令测试配置文件。
<span class="token function">sudo</span> netplan try<span class="token function">sudo</span> netplan trysudo netplan try
注意:
还有一个点,平时,我们需要注意,比如我们把一个镜像导入到另外一个环境中,要留意新环境下,我们的接口名是不是变了,注意 修改配置文件中的这个接口enp0s3
名字!
三、[推荐]官网安装包安装指定版本go
推荐:参考URL: https://docker.blog.csdn.net/article/details/106640377
1)下载安装
安装1.17.2 版本go
<span class="token function">wget</span> https://golang.google.cn/dl/go1.17.2.linux-amd64.tar.gz <span class="token parameter variable">-O</span> /tmp/go1.17.2.linux-amd64.tar.gz <span class="token function">mkdir</span> <span class="token parameter variable">-p</span> <span class="token environment constant">$HOME</span>/go <span class="token function">tar</span> <span class="token parameter variable">-xvzf</span> /tmp/go1.17.2.linux-amd64.tar.gz <span class="token parameter variable">-C</span><span class="token function">wget</span> https://golang.google.cn/dl/go1.17.2.linux-amd64.tar.gz <span class="token parameter variable">-O</span> /tmp/go1.17.2.linux-amd64.tar.gz <span class="token function">mkdir</span> <span class="token parameter variable">-p</span> <span class="token environment constant">$HOME</span>/go <span class="token function">tar</span> <span class="token parameter variable">-xvzf</span> /tmp/go1.17.2.linux-amd64.tar.gz <span class="token parameter variable">-C</span>wget https://golang.google.cn/dl/go1.17.2.linux-amd64.tar.gz -O /tmp/go1.17.2.linux-amd64.tar.gz mkdir -p $HOME/go tar -xvzf /tmp/go1.17.2.linux-amd64.tar.gz -C
原文链接:https://blog.csdn.net/inthat/article/details/118000596