Google Cloud 终端连接

阅读更多

 

一. 查看VM实例名称

test@cloudshell:~ (test-206504)$ whoami
test

 

二. 本地生成密钥对

$ cd ~/.ssh
$ ssh-keygen -f cloudkey		#设置密码

  

修改公钥用户名

cat cloudkey.pub 

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAxxxGVBvsDfN9gyQDFXJtZjSaH3afh0YDn9v5k30xBH7meH6l+SbEZ3NHZpQ== sun@localhost

sun@localhost 改为 sun@test

 

三. 导入公钥

Google Cloud Platform --> Compute Engine --> 元数据 --> SSH密钥 --> 添加cloudkey.pub内容

 

四. 本地登录

cd ~/.ssh
ssh -i cloudkey [email protected]
Enter passphrase for key 'cloudkey': 
Linux instance-1 4.16.0-0.bpo.1-amd64 #1 SMP Debian 4.16.5-1~bpo9+1 (2018-05-06) 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: Fri Jun  8 09:31:01 2018 from 58.240.100.10
sun@instance-1:~$ 

 

 五. 密码登录

网页通过SSH登录云服务器

vi /etc/ssh/sshd_config
PasswordAuthentication no     

 

发现默认是关闭密码登录的,开启并设置密码。

#设置root密码
$ sudo -i 
$ passwd 
#开启密码登录 
$ vi /etc/ssh/sshd_config
PermitRootLogin yes
PasswordAuthentication yes
$ systemctl restart sshd

 

 

参考链接

 

 

 

 

你可能感兴趣的:(Google,SSH)