不需要反引号的运行ssh复杂远程命令方式

Posted by 4Aiur on 06/07/2010 in Shell |

不需要反引号的运行ssh复杂远程命令方式 之前当我需要执行复杂的运程命令时,总是要先处理好引号、变量等问题,之后再执行命令写起来太麻烦,今天在commandlinefu上学了一招非常棒的方法,记录一下。 举个例子,之前需要用\反引$符号 [root@localhost ~]# ssh 127.0.0.1 -l root “echo a b c | awk ‘{print \$2}'” b 现在我们可以把复杂的命令写到文件中执行。 [root@localhost ~]# cat cmd echo a b c | awk ‘{print $2}’ 方法1: [root@localhost ~]# ssh 127.0.0.1 -l root “$( 方法2: [root@localhost ~]# ssh 127.0.0.1 -l root “cat cmd” b 方法3,使用标准输入执行,输入完毕后使用ctrl-D提交命令: [root@localhost ~]# ssh 127.0.0.1 -l […]

Tags: ,

使用ssh实现系统管理的自动化

Posted by 4Aiur on 03/31/2010 in SysAdmin |

使用ssh实现系统管理的自动化 常见的几种ssh认证方式: 密码认证 使用明文密钥 使用加密密钥 从安全角度考虑,建议使用第三种方式“使用加密密钥”实施自动化。 一、密码认证的自动化 使用伪终端与SSH进行交互(例如,使用类似expect的工具) 一个更改密码的小例子 #!/bin/sh # SCRIPT: chpass # # AUTHOR: Kevin Lee # # DATE: 05-17-2006 # # PURPOSE: This script is change nodes password. # # # REV: 1.0.A # # REV.LIST: # # # set -x # Uncomment to debug this script # set -n # Uncomment […]

Tags: ,

Copyright © 2010-2024 4Aiur All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.