sshpass Command : Non-interactive Password Authentication with SSH

Overview :

Linux system Admins  normally login to the linux  servers either supplying a password, or using keybased authentication. sshpass is a tool which allows us to automatically supply password to the command prompt so that automated scripts can be run as desired by users. sshpass supplies password to ssh prompt using adedicated tty , fooling ssh to believe that a interactive user is supplying password.

Some of the common uses of sshpass :

1.taking backups to a remote server

2.executing commands on systems at a specified time.

SSHPASS Installation :

1) Centos Based distributions

Setup the EPEL repository from and then run

As root run

# yum -y install sshpass

2) Ubuntu/Debain based distributions

As root run

# apt-get install sshpass

3)Compile & install from the source

#wget -O sshpass.tar.gz
#tar -zxvf sshpass.tar.gz 
#cd sshpass-1.05/ 
# make 
# make install
#which sshpass

Getting 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 should be used

sshpass is dead-easy to use. Instead of using the ssh user@remotehost command to establish an SSH connection, use the sshpass -p ‘password’ ssh user@remotehost command which automatically passes the specified password. Specifying the password as part of a command is not good security practice. A better approach is to export the password as the SSHPASS environment variable, and then use sshpass with the -e parameter:

export SSHPASS=password
sshpass -e ssh user@remotehost

Example:1 Supply Password with SSH

# sshpass -p 'password' ssh -l root -o StrictHostKeyChecking=no

Where :

password’ is the password of your server( ‘StrictHostKeyChecking=no’ is used to control logins to machines whose host key is not known or has changed

Example:2 To run some command on the remote server viz checking uptime and uname

# sshpass -p 'password' ssh -l root -o StrictHostKeyChecking=no "uptime;uname -a"

Sample Output

14:24:39 up 5 days, 20:33, 21 users,  load average: 0.61, 0.41, 0.50
Linux 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

The Best Websites to Learn Coding Online


The Learn to Code movement has picked up momentum worldwide and that is actually a good thing as even basic programming skills can have a major impact. If you can teach yourself how to write code, you gain a competitive edge over your peers, you can think more algorithmically and thus can tackle problems more efficiently.

Don’t just download the latest app, help redesign it. Don’t just play on your phone, program it. — Obama.

There’s no reason why shouldn’t know the basics of coding. You can automate tasks, you can program your Excel sheets, improve workflows, you can extract data from websites and accomplish so much more with code. You may not be in the business of writing software programs but knowing the basics of coding will help you communicate more effectively with developers.

Gone are the days when you had to enroll in expensive computer training classes as now exist a plethora of web-based courses that will help you learn programming at your own pace in the comfort of your web browser.

The Best Sites to Learn Programming

If you are ready to take the plunge, here are some of the best websites that offer courses in a variety of programming languages for free. I have also added a list of companion ebooks that will give you a more in-depth understanding of the language and they don’t cost anything either.

Online Courses & Screencasts Programming Books (Free)
JavaScript Code Academy, Learn Street, Khan Academy,Code Combat, Code Avengers Eloquent JavaScript, JavaScript Guide, Speaking JS, JS The Right Way, Oh My JS,Canvassing
HTML & CSS Code Academy, Don’t Fear The Internet, Tutsplus,Learn Layout, A to Z CSS,Dash, Web Accessibility,The Hello World Mozilla, Dive into HTML5, 20 Things I Learned, HTML Dog,HTML & CSS, HTML5 for Designers, DOM Enlightenment, HTML Canvas
jQuery Code Academy, Tutsplus,Code School jQuery Fundamentals, Learn jQuery
Python Code Academy, Google,Learn Street, Python Tutor,IHeartPY Python for You and Me,  Dive into Python, Learn Python the Hard Way, Think Python,Python for Fun, Tango with Django, Django
Ruby & Ruby on Rails Code Academy,TryRubyCode Learn,Railscasts, Rubymonk,Learn Street Why’s (Poignant) Guide to Ruby, Learn Ruby the Hard Way, Learn to Program, Learn Rails by Example
PHP Code Academy PHP Programming, Practical PHP
Google Apps Script Getting Started, Office Hours, Google Scripts Examples,Learning Apps Script
WordPress Treehouse, WordPress TV
Linux & Shell Scripting, Explain Shell Conquer the Command Line
Node.js Nodetuts, Node School The Node Beginner Book,Mixu’s Node book, Node Up and Running, Mastering Node.js
Angular JS Code School, Egg Head,Learn Angular Angular JS Tutorial, Thinking Angular, Angular Tutorial,Getting Started (Adobe)
Git (version control) Code School, Git Immersion, GitHub Training Pro Git, Learn Git
Objective-C (iOS & Mac) Code School, Stanford, iTunesU
Chrome Dev Tools Code School, Dev Tools Secret, Chrome Dev Tools Tutorial,Udacity, Building Browser Apps
Go Language, GopherCasts Programming in Go, Go by Example, Learning Go
Java Learn Java, Coding Bat,Java Udemy, Learneroo Programming in Java, Thinking in Java, O’Reilly Learning Java,Think Java, Java & CS, Java for Python Devs
Android App Development Udacity (Google Developers), Coursera, The New Boston, Google University, App Development Essentials, Code Learn, App Inventor (Visual)
D3 (data visualization) Data Visualization for the Web, Dashing D3, D3 Tips & Tricks
SQL (Databases) SQL Zoo, SQL @Stanford, Essentail SQL, SQL for Nerds
Everything Else Udacity,, Coursera, Udemy$, Lynda$, Pluralsight$,Treehouse$, Open Consortium, One Month Rails$

Teach Kids to Code

If there are kids in the family, you should download either Tynker (Android/iOS) or the Hopscotch app for iPad and they can learn the basics of programming through games and puzzles.

There’s also Scratch, an MIT project that allows kids to program their own stories and games visually. Scratch is available as a web app or you can download it on your Mac/Windows/Linux computer for offline use. Blockly and Alice are some other desktop apps that will introduce the concepts of computer progamming to your children.

On a related note, the following chart from Google Trends shows the relatively search popularity of various programming languages over the last 5 years. JavaScript clearly has maintained the lead.

[Source : Amit Agrwal]