前言
在日常的服务器管理和开发工作中,我们每天可能需要无数次地登录远程服务器。传统的密码登录方式不仅繁琐——需要我们记住并输入复杂的密码,更重要的是,它将我们的服务器暴露在被暴力破解的风险之下。
有没有一种方法,既能让我们安全地连接服务器,又能免去重复输入密码的烦恼呢?
答案是肯定的。那就是使用 SSH 密钥对进行身份验证。这篇博客将带你一步步配置 SSH 密钥登录,让你的服务器连接既安全又高效。
在日常的服务器管理和开发工作中,我们每天可能需要无数次地登录远程服务器。传统的密码登录方式不仅繁琐——需要我们记住并输入复杂的密码,更重要的是,它将我们的服务器暴露在被暴力破解的风险之下。
有没有一种方法,既能让我们安全地连接服务器,又能免去重复输入密码的烦恼呢?
答案是肯定的。那就是使用 SSH 密钥对进行身份验证。这篇博客将带你一步步配置 SSH 密钥登录,让你的服务器连接既安全又高效。
Use ssh to connect to Google Virtual Machine
谷歌云服务器默认登录方式是browser ssh,但是有时候我们需要第三方客户端使用ssh连接服务器。
本文介绍如何使用ssh连接Google Cloud平台的虚拟机(云服务器)
Use ssh to connect to AWS EC2 instance
cd command to navigate to the directory where your private key file is located.1 | chmod 400 /path/my-key-pair.pem |
ec2-user with the appropriate user name for your AMI.ec2-user. centos. admin. ec2-user or fedora. ec2-user or root. ec2-user or root. ubuntu. Here my OS is Ubuntu.ec2-user and root don’t work, check with your AMI provider.1 | ssh -i /path/my-key-pair.pem user_name@ip_address |
1 | ssh user_name@my-instance-ip |
Permission denied (publickey) error.To fix it.
1 | ssh -i /path/my-key-pair.pem user_name@ip_address |
1 | sudo passwd ubuntu |
1 | sudo vim /etc/ssh/sshd_config |
Find the Line containing PasswordAuthentication parameter and change its value from no to yes.
1 | PasswordAuthentication yes |
If you want to set up root login, find PermitRootLogin parameter and change its value from prohibit-password to yes
1 | PermitRootLogin yes |
After this changes save file and exit.
1 | service ssh restart ## for ubuntu |
1 | chmod 400 /path/my-key-pair.pem |
1 | ssh user_name@my-instance-ip |