保存 ssh-key

1
2
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 500 .ssh/authorized_keys

禁用密码登录与改端口

1
sudo vim /etc/ssh/sshd_config
1
2
3
4
5
6
7
8
9
10
11
12
13
Port 22

# 启用密钥验证
RSAAuthentication yes # below 16.0
PubkeyAuthentication yes


# 指定公钥数据库文件
AuthorizedKeysFile %h/.ssh/authorized_keys # below 16.0
AuthorizedKeysFile .ssh/authorized_keys # 18.0

PasswordAuthentication no

1
sudo service sshd restart

or

1
sudo service ssh restart