Linux系统(或者WSL)在/home目录下查看是否存在.ssh文件夹,文件夹内是否存在id_rsa.pub文件;Windows系统可以使用Git Bash终端查看是否存在.ssh文件夹,文件夹内是否存在id_rsa.pub文件存在该文件证明已经有ssh-key了,如果没有执行下一步,生成ssh-key。
SSH-KEYLinux环境下可以直接使用指令:
ssh-keygen -t rsa -C "你的邮箱"
如果是Windows环境下,使用Git Bash终端执行同样的命令。
找到.ssh文件夹下的id_rsa.pub文件,复制其中的内容。
在服务器页面,选择左侧的密钥选项,然后在右侧点击创建密钥

在创建SSH密钥添加页面
ssh-key


在终端使用以下命令连接服务器:
ssh 用户名@IP地址
例如:
ssh ubuntu@12.34.56.78
连接成功效果如下:
xxxx@LAPTOP-xxxx:~/.ssh$ ssh ubuntu@12.34.56.78 Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-126-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Wed 16 Nov 2022 03:08:03 PM CST System load: 0.49 Processes: 139 Usage of /: 6.1% of 78.64GB Users logged in: 0 Memory usage: 8% IPv4 address for eth0: 13.0.24.5 Swap usage: 0% => There is 1 zombie process. * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s just raised the bar for easy, resilient and secure K8s cluster deployment. https://ubuntu.com/engage/secure-kubernetes-at-the-edge Last login: Wed Nov 2 16:00:30 2022 from 123.113.81.186
使用exit命令可以断开ssh连接。