Saltar al contenido

~ / archivo / stackoverflow / 18475802

How to switch users in Cygwin?

StackOverflow · cygwin · ayudé
  1. user2495173 pregunta +8 2013-08-27 21:29

    I am trying to switch users in Cygwin using Cygwin's login command. It throws an error saying:

    /bin/bash: No such file or directory. Operation not permitted.
    

    I am new to Cygwin. How I can switch between users?

    • Kisaragi 2013-08-27 21:31 su {username} {password}
    • user2495173 2013-08-27 21:31 that does not work either, it gives the same error. I have added user in Windows, how do I add that user in cygwin?
    • Kisaragi 2013-08-27 21:35 Try ssh: ssh username@localhost
    • user2495173 2013-08-27 21:36 $ ssh gundu@localhost gives the following error ssh: connect to host localhost port 22: Connection refused
    • user2495173 2013-08-27 21:38 when I type /etc/passwd I get the following, do you see any problem?/etc/passwd: line 9: gundu:unused:1008:513:gundu,U-BSA25G-SWLABgundu,S-1-5-21-606‌​747145-1078145449-72‌​5345543-1008:/home/g‌​undu:/bin/bash: No such file or directory
    • Kisaragi 2013-08-27 21:39 This is most likely a firewall issue.
    • user2495173 2013-08-27 21:40 what should I do to fix it?
    • David Duncan 2013-08-27 21:42 Does this link help?
    • Kisaragi 2013-08-27 21:43 Check your firewall. Add an exception for port 22. This should work after : ssh gundu@localhost
    • user2495173 2013-08-27 21:50 When I click on Windows Firewall in Control Panel it says "Windows Firewall settings cannot be displayed because the associated service is not running. Do you want to start the Windows Firewall/Internet Connection Sharing(ICS) service?"
    • user2495173 2013-08-27 21:54 @DavidDuncan I did refer this link, but no luck.
    • Keith Thompson 2013-08-28 01:29 @Kisaragi: You have to be running the sshd service for ssh to a Cygwin box to work; it doesn't run by default. There are instructions here for Cygwin under Windows 7. You shouldn't need to go through ssh just to switch users, though. (I've been using Cygwin for a long time, but I've never bothered setting up more than just my own user account.)
    • Keith Thompson 2013-08-28 03:17 You haven't said how you're trying to switch users, other than "with Login User Password format". Are you using the login command? I've just tried that myself, and I get login: no shell: /bin/bash: Operation not permitted, which isn't what you reported. I am able to login using ssh, but only because I've set up the sshd service. I don't know why login doesn't work. You might try asking on the cygwin mailing list.
    • user2495173 2013-08-28 22:10 @KeithThompson: You are correct when I use the login command, i get the login: no shell: /bin/bash: Operation not permitted message. How do I login using ssh? How to check if sshd service is running or not?
    • user2495173 2013-08-28 22:15 I tried $ ssh gundu@bsa25g-SWLAB ssh: connect to host bsa25g-SWLAB port 22: Connection refused is the message I get.
    • Keith Thompson 2013-08-28 22:22 @user2495173: If you installed Cygwin on the system, and you don't know whether you're running the sshd service, you probably aren't. See the instructions I posted previously. What version of Windows are you using?
    • user2495173 2013-08-28 22:33 This is what I get: stambi@bsa25g-SWLAB /cygdrive/c/Documents and Settings/gundu $ cygrunsrv -Q sshd Service : sshd Display name : CYGWIN sshd Current State : Stopped Command : /usr/sbin/sshd -D stambi@bsa25g-SWLAB /cygdrive/c/Documents and Settings/gundu $ /usr/sbin/sshd -D /var/empty must be owned by root and not group or world-writable.
    • user2495173 2013-08-28 22:55 I did ssh-host-config, now I am able to switch from stambi to gundu but when I swicth from gundu to stambi, it does not allow. It says Permission denied (publickey,password,keyboard-interactive).
  2. Miguel Ortiz yo respuesta +3 2017-06-01 12:50

    I don't know why login doesn't work. But I have an easy workaround for this, running cygwin as the desired user, you can use RUNAS or automatize something using PSEXEC.

    RUNAS:

    runas /user:HOSTNAME\<user> D:\cygwin-64\Cygwin.bat
    

    PSEXEC:

    psexec \\HOSTNAME -u DOMAIN\<user> -p <password> D:\cygwin-64\Cygwin.bat
    

    You even can pass commands/run scripts silently to Cygwin like this:

    psexec -accepteula \\HOSTNAME -u DOMAIN\<user> -p <password> D:/cygwin-64/bin/run.exe /usr/bin/bash -lic \"/home/username/file.sh\"
    

    Although the question is quite old maybe someone else is looking for this. I've documented this and other options here.

← todos los hilos de StackOverflow