ssh一些小技巧

免密登陆

ssh 免密码

1
2
ssh-keygen # 生成密钥对
ssh-copy-id <用户名@主机> -p port

对服务器

1
2
3
chmod 600 .ssh/authorized_keys
chmod 700 .ssh
sudo vi /etc/ssh/sshd_config

/etc/ssh/sshd_config

1
2
3
4
5
6
RSAAuthentication yes 
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

PermitRootLogin no //禁止root登录
PasswordAuthentication yes //允许密码登录,根据你的情况设置

端口转发

(待更新)

GitHub ssh

添加到github中:

Settings–SSH and GPG Keys–Add SSH Key,粘贴 id_rsa.pub

验证:

1
ssh -T git@github.com

提示成功:

1
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.
-------------end-------------
  • 本文作者: ouyen
  • 本文链接: https://ouyen.github.io/ssh/
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!