Skip to content

Instantly share code, notes, and snippets.

@jpzhu
Last active December 13, 2018 09:38
Show Gist options
  • Save jpzhu/1a3ff03d7a4aaeb579dab45917d20692 to your computer and use it in GitHub Desktop.
Save jpzhu/1a3ff03d7a4aaeb579dab45917d20692 to your computer and use it in GitHub Desktop.
sshd root ssh
# 禁止密码登录
PasswordAuthentication no
# 禁止Root登录
PermitRootLogin no
# 网开一面
Match Address 172.xx.yy.zz
PermitRootLogin yes
# 重启sshd服务
service sshd restart
#禁用某个账号登录
# 在~/.ssh/authorized_keys 可以增加command执行ssh后的操作
no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"ec2-user\" rather than the user \"root\".';echo;sleep 10" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAoXbOTG1wKV/+BKYd yiba-aws
# 启动端口转发
GatewayPorts yes
@jpzhu
Copy link
Author

jpzhu commented Nov 14, 2017

ssh出现permission denied (publickey)问题:
修改/etc/ssh/sshd-config文件.
将其中的PermitRootLogin no修改为yes
PubkeyAuthentication yes修改为no
AuthorizedKeysFile .ssh/authorized_keys前面加上#屏蔽掉,
PasswordAuthentication no修改为yes就可以了。

利用私钥恢复公钥
ssh-keygen -y -f private.pem

@jpzhu
Copy link
Author

jpzhu commented Dec 13, 2018

/eth/ssh/ssh_config 客户端配置和服务器长连接。
TCPKeepAlive yes
ServerAliveInterval 30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment