Tag: Shell
Shell Command sshpass non-interactive SSH password verification
# Install sshpasssshpass
: Http://sourceforge.net/projects/sshpass/
Download it as a tar.gz compressed package.
$ Tar-zxvf sshpass-1.05.tar.gz
$ Sshpass-1.05 CD
$./Configure -- prefix =/opt/sshpass
# Specify the installation directory
$ Make
$ Make install
$ CP/opt/sshpass/bin/sshpass/usr/bin/
Installation Complete
# View help
Sshpass-H
Usage: sshpass [-f |-d |-p |-E] [-HV] Command Parameters
-F filename take password to use from File
-D Number use number as file descriptor for getting Password
-P password provide password as argument (Security unwise)
-E password is passed as env-Var "sshpass"
With no parameters-password will be taken from stdin
-H Show Help (this screen)
-V print version information
At most one of-F,-D,-P or-e shoshould be used
#! /Bin/bash
CD $ (dirname $0)
Source./config. Sh
Date = 'date + % Y-% m-% d'
# Upload the dump script to the server
Sshpass-pyour_pwd SCP-P22./dump. Sh your_user@192.168.1.10 :~ /
#-O stricthostkeychecking = No to avoid public key check during the first logon.
Sshpass-pyour_pwd SCP-O stricthostkeychecking = No-P22./dump. Sh your_user@192.168.1.10 :~ /
# Log on to the server address and run the dump script to write the execution result to a local file.
Sshpass-pyour_pwd ssh-P22 your_user @ 192.168.1.10 "Sh ~ /Dump. Sh "> local_result.txt
# Use the password in the file
Sshpass-f pwd. File ssh-P22 your_user@192.168.1.10 "Sh ~ /Dump. Sh "> local_result.txt
# Read the password from the environment variable (sshpass)
Sshpass-e ssh-P22 your_user@192.168.1.10 "Sh ~ /Dump. Sh "> local_result.txt
Shell Command sshpass non-interactive SSH password verification