yzh648
(云铮)
1
### 谷歌云创建服务器、设置防火墙、密码登录
https://www.youtube.com/watch?v=Oo1JE8l-LRA
### 清除iptables防火墙
作用:清空iptables默认的防火墙规则,避免后续产生影响,最省事儿方案,大佬也可以自己放通端口
~~~
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F
apt-get purge netfilter-persistent -y
~~~
### 设置服务器密码登录
~~~
sudo -i #获得root权限
vi /etc/ssh/sshd_config #vi打开配置文件
~~~
https://dewx.top/wp-content/uploads/2024/02/Snipaste_2024-02-20_09-11-10-921x1024.png
~~~
#设置服务器密码登录
将 PermitRootLogin及PasswordAuthentication两个参数更改为yes
service sshd restart #改完两行之后,重启服务
passwd #输入修改密码命令,然后输入两次密码即可修改密码成功
注意:linux输入密码是不显示的
~~~
### 由@"liulisanwan"#2170 大佬提供的方法
~~~
sudo -i
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
systemctl restart sshd
后面输入passwd输入新密码就好了
~~~
### 谷歌云设置安全组
https://youtu.be/3PdPMxniDGI?si=N43QZQKAbiNxGJdR
### 谷歌云更换ip
https://www.youtube.com/watch?v=VDdsEhluk6o
yzh648
(云铮)
8
@“呦吼”#p32621 你要花钱买啊?谷歌云很贵的
hahahaya
(hahahaya)
9
@“云铮”#p32655 不买不买就是问问:ac06:
sudo -i
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sed -i 's/^#*PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/^#*PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config
systemctl restart sshd
一键搞定。
后面输入passwd输入新密码就好了
yzh648
(云铮)
11
@“liulisanwan”#p32692 @James 试试看?
@“云铮”#p32715 我手里所有的服务器都是这样玩的。先sudo -i 后面直接一键修改配置文件。让某些小白是用vim不如直接一个命令就改好。让他直接改密码即可
yzh648
(云铮)
14
@“liulisanwan”#p32716
,我让版主置顶一下你的评论
@“James”#1
@"liulisanwan"#p32716 🆗了我修改了一下教程
James
(James)
15
@“云铮”#p32727 哈哈,NL暂时还没有这个功能。
yzh648
(云铮)
16
@“liulisanwan”#p32692 出错了呀
~~~
root@us-west-la:~# sudo -i
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sed -i ‘s/^#PermitRootLogin ./PermitRootLogin yes/’ /etc/ssh/sshd_config
sed -i ‘s/^#PasswordAuthentication ./PasswordAuthentication yes/’ /etc/ssh/sshd_config
systemctl restart sshd
root@us-west-la:~# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
root@us-west-la:~# sed -i ‘s/^#PermitRootLogin ./PermitRootLogin yes/’ /etc/ssh/sshd_config
sed: -e expression #1, char 1: unknown command: `’
root@us-west-la:~# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sed -i ‘s/^#PermitRootLogin ./PermitRootLogin yes/’ /etc/ssh/sshd_config
sed -i ‘s/^#PasswordAuthentication ./PasswordAuthentication yes/’ /etc/ssh/sshd_config
systemctl restart sshd
sed: -e expression #1, char 1: unknown command: ' sed: -e expression #1, char 1: unknown command:
'
~~~
@“云铮”#p32737 你复制的字符串有问题。'应该是英文,你这上边好像不对
`
iii123789z@instance-20240529-065856:~$ sudo -i
root@instance-20240529-065856:~# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sed -i 's/^#*PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/^#*PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config
systemctl restart sshd
root@instance-20240529-065856:~# ^C
root@instance-20240529-065856:~# passwd
New password:
Retype new password:
passwd: password updated successfully
root@instance-20240529-065856:~#
`
yzh648
(云铮)
19
@“liulisanwan”#p32750 可能是格式的问题,我改了一下
dwad
(dwad)
20
我觉得gcp不好玩(其实是3个月实在是没啥好用处),所以我都懒得折腾,