1、编译安装
git clone https://github.com/janmojzis/tinyssh.git
cd tinyssh-master
make && make install
mkdir /etc/tinyssh && tinysshd-makekey /etc/tinyssh/sshkeydir
2、编写systemd文件
cat > /etc/systemd/system/[email protected] << EOF
[Unit]
Description=Tiny SSH server
After=network.target auditd.service
[Service]
ExecStartPre=-/usr/sbin/tinysshd-makekey -q /etc/tinyssh/sshkeydir
EnvironmentFile=-/etc/default/tinysshd
ExecStart=/usr/sbin/tinysshd ${TINYSSHDOPTS} -- /etc/tinyssh/sshkeydir
KillMode=process
SuccessExitStatus=111
StandardInput=socket
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
cat > /etc/systemd/system/tinysshd.socket << EOF
[Unit]
Description=TinySSH server socket
ConditionPathExists=!/etc/tinyssh/disable_tinysshd
[Socket]
ListenStream=10022
Accept=yes
[Install]
WantedBy=sockets.target
EOF
3、启动服务
systemctl daemon-reload
systemctl enable tinysshd.socket
systemctl restart tinysshd.socket
systemctl status tinysshd.socket
4、生成密钥对
ssh-keygen -t ed25519
5、将公钥放在认证文件中私钥保存在本地使用私钥登录
cat /root/.ssh/id_ed25519.pub >> /root/.ssh/authorized_keys
sz /root/.ssh/id_ed25519
6、卸载
rm -rf /usr/sbin/tinysshd
rm -rf /usr/sbin/tinysshd-makekey
rm -rf /usr/sbin/tinysshd-printkey
rm -rf /usr/share/man/man8/tinysshd.8
rm -rf /usr/share/man/man8/tinysshd-makekey.8
rm -rf /usr/share/man/man8/tinysshd-printkey.8
rm -rf /usr/share/man/man8/tinysshnoneauthd.8
rm -rf /etc/tinyssh
rm -rf /etc/systemd/system/tinysshd.socket
rm -rf /etc/systemd/system/[email protected]
rm -rf /root/.ssh/id_ed25519.pub
rm -rf /root/.ssh/id_ed25519
标签:教程,部署,tinysshd,etc,rf,TinySSH,usr,rm,ssh
From: https://www.cnblogs.com/wanghongwei-dev/p/18376383