I am trying to create a new user on a server using ssh like this:
ssh root@myserver 'adduser newuser'
It runs successfully, but ssh does not stops and hangs until I hit Ctrl+C. What can I do with this?
The adduser
is interactive and for that TTY is needed. Run the ssh
command with -t
switch to make sure TTY is allocated on server:
ssh -t root@myserver 'adduser newuser'
adduser
may be interactive and thus waits for input?adduser
so, that it doesn't wait for input, thus exiting and closing your SSH session.