Change Password Using passwd Command Over SSH Based Session

by on October 4, 2013 · 2 comments· LAST UPDATED October 15, 2013

in , , ,

I'm a new Ubutnu Linux user. I backup files to our corporate Unix backup server using the rsync command. The server only allow to upload/download files. I am unable to login to the server. How do change my password using the passwd command over ssh based session?

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
RequirementsNone
Estimated completion time2m
For security reasons, your ssh based account has limited access to the server. You can only upload or download files using scp, sftp, rsync and so on. You may execute limited number of commands such as passwd, ls and so on.

Also, it is a good idea to change your password every month or at least every four months. Make sure you use combination of alphabets (upper and lower case characters), numbers, and special characters as a password to safeguard your account. You should choose a password of at least ten characters.

Syntax

The syntax is:

 
ssh -t user@server-name-here passwd
ssh -t userName@server.ip.address.here passwd
ssh -t userName@192.168.1.20 passwd
ssh -t userName@192.168.1.20 /bin/passwd
 

Where,

  • -t : This option force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs (such as passwd) on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

Examples

In this example, change password for user called nixcraft on server1.cyberciti.biz by issuing the passwd command over ssh:

 
ssh -t nixcraft@server1.cyberciti.biz passwd
ssh -t vivek@nas01 passwd
 

Sample outputs:

Animated gif 01: Change password using the passwd command over ssh

Animated gif 01: Change password using the passwd command over ssh

Warning: If you skip the -t option, either you will see password in a plain text on screen or you will get an error that read as follows:

passwd: pam_chauthtok(): conversation failure

In this example, change password for user called vivek on nas01 by issuing the passwd command without the -t over ssh:

 
ssh nixcraft@server1.cyberciti.biz passwd
ssh vivek@nas01 passwd
 

Sample outputs:

Animated gif 02: Change password using the passwd command without -t option over ssh. Note down the password shown in clear text.

Animated gif 02: Change password using the passwd command without -t option over ssh. Note the password is shown in clear text.

See also
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 2 comments… read them below or add one }

1 simon October 6, 2013 at 11:53 pm

Does this work with scponly?

Reply

2 nixCraft October 7, 2013 at 2:20 am

Yes, as long as scponly compiled with --enable-passwd-compat flag.

HTH

Reply

Leave a Comment

Tagged as: , , , , , , , ,

Previous Faq:

Next Faq: