linux apline - ssh服务安装及免密登陆实现
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了linux apline - ssh服务安装及免密登陆实现,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2024字,纯文字阅读大概需要3分钟。
内容图文
![linux apline - ssh服务安装及免密登陆实现](/upload/InfoBanner/zyjiaocheng/922/fc46a14a0b8e4c829e52711d58cdfc64.jpg)
目标机器
安装ssh服务
apk add openssh-server
apk add openssh
sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config && sed -i "s/#Port.*/Port 22/g" /etc/ssh/sshd_config && ssh-keygen -t dsa -P "" -f /etc/ssh/ssh_host_dsa_key && ssh-keygen -t rsa -P "" -f /etc/ssh/ssh_host_rsa_key && ssh-keygen -t ecdsa -P "" -f /etc/ssh/ssh_host_ecdsa_key && ssh-keygen -t ed25519 -P "" -f /etc/ssh/ssh_host_ed25519_key && echo "root:****" | chpasswd. # 修改密码
/usr/sbin/sshd -D
自身机器
免密登陆2种方式
方式1
/ # ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.1.13
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
expr: warning: '^ERROR: ': using '^' as the first character
of a basic regular expression is not portable; it is ignored
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.1.13's password: #提示输入密码
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.1.13'"
and check to make sure that only the key(s) you wanted were added.
/ # ssh 192.168.1.13
Welcome to Alpine!
The Alpine Wiki contains a large amount of how-to guides and general
information about administrating Alpine systems.
See <http://wiki.alpinelinux.org/>.
You can setup the system with the command: setup-alpine
You may change this message by editing /etc/motd.
方式2: 将公钥文件拷到目标机器
# scp -p ~/.ssh/id_rsa.pub root@192.168.1.13:/root/.ssh/authorized_key
id_rsa.pub 100% 571 640.3KB/s 00:00
# 测试登录
/ # ssh 192.168.1.13
Welcome to Alpine!
The Alpine Wiki contains a large amount of how-to guides and general
information about administrating Alpine systems.
See <http://wiki.alpinelinux.org/>.
You can setup the system with the command: setup-alpine
You may change this message by editing /etc/motd.
内容总结
以上是互联网集市为您收集整理的linux apline - ssh服务安装及免密登陆实现全部内容,希望文章能够帮你解决linux apline - ssh服务安装及免密登陆实现所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。