亞馬遜AWS實例的登錄方式都是密鑰登錄,我我的以爲很不方便,不太習慣,因而記錄一下修改成帳號密碼登錄的過程。shell
用密鑰登錄到centos,下面是xshell的登錄設置centos
登錄的時候選擇用戶記得選centos,root用戶是登錄不上的。ssh
WARNING! The remote SSH server rejected X11 forwarding request. Please login as the user "centos" rather than the user "root".
1.先給root用戶設置密碼rest
sudo passwd root
2.切換到root用戶code
su root
3.輸入如下命令啓用用戶名密碼登錄server
sed -ri 's/^#?(PasswordAuthentication)\s+(yes|no)/\1 yes/' /etc/ssh/sshd_config sed -ri 's/^#?(PermitRootLogin)\s+(yes|no)/\1 yes/' /etc/ssh/sshd_config sed -ri 's/^/#/;s/sleep 10"\s+/&\n/' /root/.ssh/authorized_keys
4.重啓sshd生效rem
service sshd restart