Last active
December 14, 2015 18:09
-
-
Save simkimsia/5126919 to your computer and use it in GitHub Desktop.
change shell for any user to use /bin/bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
### | |
# | |
# Copyright (c) 2013 KimSia Sim | |
# | |
# Ubuntu 12.10 based change shell for users | |
# Run this by executing the following from a fresh install of Ubuntu 12.10 server: | |
# | |
# expect -c "$(curl -fsSL https://raw.github.com/gist/5126919)" <username> <password> | |
# | |
# Be sure to replace <username> with your intended username and <password> with your intended password. | |
# Also, run this as root, unless you enjoy failing. | |
# Be sure you have installed expect. Run apt-get install expect before this. | |
# | |
# Its handy to install 'screen' if you want to ensure your remote connection to | |
# a server doesn't disrupt the installation process. If you want to do this, just | |
# do the following before running the main bash command: | |
# | |
# apt-get install screen -y | |
# screen | |
# | |
# To recover your session if you are disconnected, ssh to your server as root again, | |
# and type: | |
# | |
# screen -x | |
# | |
# Dependencies: | |
# - curl | |
# | |
# Todo: | |
# - SSL Configuration | |
# | |
### | |
set CHANGESHELL_FOR_USER [lindex $argv 0]; | |
set PASSWORD_OF_USER [lindex $argv 1]; | |
######################################## | |
## switch to another user | |
## read this http://stackoverflow.com/a/1988255/80353 | |
######################################## | |
sudo -u $CHANGESHELL_FOR_USER -H sh -c "chsh -s /bin/bash" | |
expect "*?assword:*" {send -- "$PASSWORD_OF_USER\r";} | |
expect eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment