拥有用一台云服务器可以让我们做很多有趣的事情,比如创建个人博客,搭建科学上网服务,搞搞离线下载,私人云盘,内网穿透等等。VPS建在哪里好呢,本博主推荐谷歌云, 只要一张外币信用卡即可搞定,注册完毕后谷歌云提供给你一年免费的300美金赠金,可以免费试用其中的各种功能,到期后还可继续选择试用,听起来是不是赞爆。 那么这期教程就来聊聊搭建谷歌云VPS的过程及注意事项。

A cloud server allows us to do lots of interesting things, like build a website, run a personal blog, etc. It is recommended creating your VPS on Google cloud, free trial for $300 on 1 year, and fully renewable. So let’s get started.

目录 / LIST


# 前期准备 | Preparations

  • 你需要一个注册好赠金的谷歌云账号。
  • A Google Cloud account that is registered with a $300 bonus is required.
x

# 配置防火墙 | Firewall config

  • 实例创建前首先需要配置防火墙,通过VPC网络菜单进入防火墙规则页面,点击创建防火墙规则
  • Firstly let’s go to filewall settings. Select VPC Network, then Firewall rules, then Add rule.
x
  • 名称随便起,流量方向选入站,然后对匹配项执行的操作选允许,其他参数保持默认。
  • Pickup a name u like, then choose ingress, permit, other settings remain default.
x
  • 接下来,来源IP地址范围,填入0.0.0.0/0,不要遗漏后面的0,协议和端口选全部允许,其他参数保持默认,点击创建
  • Input 0.0.0.0/0 in Source IP address, and choose All allowed in Protocol and port, other settings remain default, then Create.
x
  • 创建完成后,可以回到防火墙规则页面,把其他默认的规则都删掉,因为这些规则都会被我们创建的这个新规则覆盖掉,而且谷歌云内置默认的全部允许出站流量,不需要再创建出站规则。
  • After the creation is complete, you can go back to the Firewall Rules page and delete the other default rules, because these rules will be overwritten by the new rule we created, and Google Cloud has a built-in rule to allow all egress flow, so where is no need to create one.

# 创建VM示例 | New instance

  • 点击Compute Engin,选择VM实例,然后点击创建实例
  • Select Compute Engin, then VM Instances, and Create.
x
  • 名称随便填,区域的话选台湾最快,地区随便选,机型的话选f1-micro就够用了。
  • Pick an instance name, and region based on your location. And a f1-micro is enough for use.
x
  • 然后剩下的设置都不需要改动,保持默认即可,最后点击创建
  • Other settings remain default, then click Create.
x

# IP地址筛选 | Select IP address

  • 创建完成的实例默认会分配一个动态IP地址,那这个IP速度怎样呢,还需要进行测试。
  • 一般情况下谷歌云分配的地址都是新的,但也有二手的,而且有很大几率是被墙的或者ping很高的劣质IP。
  • The instance we created will be assigned a dynamic IP address by default, and it needs to be tested.
  • There are also second-handed IP address, and there is a high probability that it is a poor quality IP that is gfwalled or the ping value is very high.
x x
  • 选中实例,点击停止,再启动,即可刷新动态IP地址,可以多试几次,直到选中满意的为止。
  • 选好IP地址后,需要把这个动态IP改为静态IP,以免实例重启后IP地址发生变化。
  • 通过VPC网络菜单进入外部IP地址页面,点击类型列中的临时,把它改为静态,名字可以随便写,最后点保留即可。
  • Select the instance, click Stop, then Start, to refresh IP address, you can try several times until you find the best one.
  • After selecting an IP address, you need to change this dynamic IP to a static IP to prevent the IP address from changing after the instance is restarted.
  • Go to the External IP Address page of the VPC Network menu, click Temporary in the Type column, change it to Static, pick a name u like, and finally Reserve.
x

# SSH登录 | SSH login

  • 如果想在电脑上通过SSH登录刚才创建的VPS,直接在VM实例中点击SSH链接即可。
  • Just click SSH link in the VM instance page, if u want to ssh your vps on PC.
x
  • 如果通过手机登录,则需要提前进行密钥设置。这里以ssh神器 Termius 为例。
  • If u are using mobile phone to ssh your VPS, u should config the keys in advance. Let’s take Termius for example.
x
  • 在app store直接下载Termius安装,然后选择Hosts,点击右上角+,选择New Host
  • Download Termius directly from the app store, then select Hosts, click on the top right corner of + and select New Host.
x
  • Alias随便填,Hostname填写刚才生成的静态IP地址,之后打开Use SSH
  • Pick a neme in Alias, fill the static IP address just generated in Hostname, then open Use SSH trigger.
x
  • 进入Key页面,然后选择Generate Key生成一对新的密钥,最后点击Save保存。
  • Go to the Key page and select Generate Key to generate a new pair of keys, then press Save.
x
  • 接下来需要将生成的新的密钥中的公钥复制下来,上传到谷歌云上。进入Keychain页面,点击key图标,选择上面第二个编辑按钮。
  • Next, you need to copy the public key and upload it to Google Cloud. Go to the Keychain page, click the key icon and select the second button above.
x
  • 往下翻,然后把Public里的内容全复制下来。
  • Scroll down and copy the contents in Public.
x
  • 回到谷歌云,VM实例页面中点击VPS的名字进入详情页,随后点上面的修改
  • Go back to Google Cloud, click on the VPS name in the VM Instances page to go to the details page, then click on Modify above.
x
  • 往下翻,找到SSH密钥,点击添加一项,然后把刚才复制的公钥粘贴进去。
  • 接下来这一步很重要:需要把Generated by Terminus这句删掉,替换成你谷歌账号的名字也就是[email protected]里的XXX,最后点更新
  • Scroll down, find the SSH key, click on ‘Add one’, and paste the public key you just copied.
  • This next step is very important: you need to delete the Generated by Terminus sentence, replace it with the name of your Google account, which is XXX in [email protected], and finally Update.
x
  • 最后回到手机上,在Hosts中直接点击刚才添加的VPS,就可以实现SSH登录啦。
  • Finally, go back to your phone and click the VPS you just added in Hosts to initiate SSH login.
x
 
• 本文作者 | Author info >> MAXH
• 来源链接 | Source link >> 谷歌云VPS入门指南 | Getting started with Google Cloud VPS
• 发表评论 | Make comments >>