使用ssh连接AWS EC2实例
cd
command to navigate to the directory where your private key file is located.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.ssh -i /path/my-key-pair.pem user_name@ip_address
Open a terminal window.
Use the following command to connect to your instance.
ssh user_name@my-instance-ip
Permission denied (publickey)
error.To fix it.
ssh -i /path/my-key-pair.pem user_name@ip_address
sudo passwd ubuntu
sudo vim /etc/ssh/sshd_config
Find the Line containing PasswordAuthentication
parameter and change its value from no
to yes
.
PasswordAuthentication yes
If you want to set up root
login, find PermitRootLogin
parameter and change its value from prohibit-password
to yes
PermitRootLogin yes
After this changes save file and exit.
service ssh restart ## for ubuntu
service sshd restart ## for centos
chmod 400 /path/my-key-pair.pem
ssh-add -k /path/my-key-pair.pem
ssh user_name@my-instance-ip
文章作者: Alan Zeng
原始链接: https://alanzeng.com/blogs/16582/
版权说明:本博客所有文章除特别声明外,均采用BY-NC-SA 4.0许可协议。获得许可后,要求转载时注明文章出处和网站链接,谢谢!
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有