shell 练习 (免密钥登陆脚本)
shell 脚本 练习 登陆 密钥
2023-09-14 09:07:48 时间
脚本说明 本地服务器ip 10.0.0.5 远程服务器地址 10.0.0.223
#!/bin/bash
remote_ip=$1 if [ ! -n "$1" ] ;then echo "please usage ./without_password remote_host!" exit 1 else echo "the remote_host you input is $remote_ip" fi ssh root@$remote_ip "mkdir .ssh; chmod 700 .ssh" ssh-keygen -t rsa scp ~/.ssh/id_rsa.pub root@$1:/root/.ssh/authorized_keys ssh root@$1 "chmod 600 ~/.ssh/authorized_keys" ssh root@$1 ifconfig
退出远程
[root@localhost ~]# exit logout Connection to 10.0.0.223 closed. eth0 Link encap:Ethernet HWaddr 00:0C:29:DD:80:F9 inet addr:10.0.0.50 Bcast:10.255.255.255 Mask:255.0.0.0 inet6 addr: fe80::20c:29ff:fedd:80f9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:9826 errors:0 dropped:0 overruns:0 frame:0 TX packets:6413 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:985311 (962.2 KiB) TX bytes:915545 (894.0 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:155 errors:0 dropped:0 overruns:0 frame:0 TX packets:155 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:16942 (16.5 KiB) TX bytes:16942 (16.5 KiB)
相关文章
- 为vagrant 启动虚拟机并登入虚拟机写一个shell脚本。
- linux shell 进去 uefi,怎么进入EFI Shell及怎么为UEFI截图「建议收藏」
- Shell脚本编程_shell简单脚本
- linux shell脚本编写实例_常用的shell脚本
- Shell脚本编程_shell脚本编程100例pdf
- 开源一个mysql备份的shell脚本
- shell脚本编写算法详解程序员
- 找出1小时内占用cpu最多的10个进程的shell脚本详解程序员
- 使用shell脚本监控cpu,磁盘,内存详解程序员
- 脚本Linux下实现精准计时的Shell脚本(linux计时shell)
- Centos下使用php调用shell脚本详解编程语言
- Shell if条件判断语句用法详解
- Shell配置文件(脚本)的加载
- 走进Linux世界:命令行与Shell脚本编程指南(linux命令行与shell脚本编程大全)
- shell脚本Linux系统中如何执行Shell脚本(linux如何执行)
- 数据使用Shell指令读取MySQL数据库(shell读取mysql)
- 脚本Linux下如何创建Shell脚本(linux创建shell)
- Linux脚本Shell编程:快速入门(linux脚本shell)
- Shell 脚本编程陷阱
- 用Shell脚本分析Nginx日志
- Mastering Linux: The Ultimate Guide to Connecting to Your System with Shell(shell连接linux)
- Linux下运行Shell脚本的简单使用技巧(linux运行shell脚本)
- 使用Shell脚本来操作Redis(shell写redis)
- VB使用shell函数打开外部exe程序的实现方法