Shell Command sshpass non-interactive SSH password verification, sshpassssh

Source: Internet
Author: User

Shell Command sshpass non-interactive SSH password verification, sshpassssh

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


In linux, how does one remotely log on to another machine using shell scripts to execute the command username/password for stopping the process: test/12345 h?

Enter the password for the ssh test@10.1.1.8.
Ps-ef view process pid
Or netstat-ntpl
Kill-9 process pid

When python calls shell commands, you sometimes need to manually enter the password (such as ssh ).

Dedicated CT is dedicated to this de
I have searched for a lot of information on the Internet. I have done this, so it is roughly as follows:
Secondary CT
Spawn ssh 192.168.1.1
Wrong CT "login :"
Send "wuhuhu"
CT "Pasword :"
Send "123456"
 

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.