前段时间使用谷歌云搭建了一个科学上网 但是每次需要通过gcp面板连接比较麻烦。所以想使用ssh直接远程

此文档做个记录

进入谷歌云实例面板

VyWdzR.jpg

切换到root角色

1
2
dylan_yanght@agent:~$ sudo -i
root@agent:~# 

修改ssh配置文件

1
root@agent:~# vim /etc/ssh/sshd_config

修改 PermitRootLogin PasswordAuthentication为yes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#LoginGraceTime 2m
PermitRootLogin yes  #默认为no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes
# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile     .ssh/authorized_keys .ssh/authorized_keys2
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes   #默认为no
#PermitEmptyPasswords no

给root用户设置密码

1
root@agent:~# passwd root

重启SSH服务使修改生效

1
/etc/init.d/ssh restart

远程连接

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[root@test ~]# ssh root@35.201.xxx.xxx
root@35.201.xxx.xxx's password:
Linux agent 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Jun 10 14:54:34 2019 from xxx.xxx.xxx.xxx
root@agent:~#

远程登录完成