Shell Command sshpass non-interactive SSH password verification

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.