Linux connect to windows cmd

How to execute Windows commands remotely from Linux machine using rdesktop command?

Is it possible to run Windows commands using rdesktop tool in Linux? I tried with rdesktop -s option:

rdesktop -u user -p 10.0.0.2 -s "cmd.exe" 
rdesktop -u user -p'password' 10.0.0.2 -s "C:\WINDOWS\system32\cmd.exe" 

but there is no difference in the RDP session even if I use -s . I’m trying to get a list of RDP sessions using qwinsta /server in Windows from Linux.

It’s probably because only the default admin can do tasks without being promoted to prpceed. Any other account, even with the correct permissions, would be acting as admin.

3 Answers 3

If you have access to the computer, install an ssh server on it. On Linux you can use for example Overlook-Fing to find the IP of the computer. Then you type ssh username@ipaddress into the Linux shell.

Then type the user’s password and you should have access to the computer’s Windows Command Prompt. You could also use telnet but ssh is encrypted.

I don’t have a solution using rdesktop but I use a program called winexe on Linux to execute remote commands on Windows machines. You can get the application from the following URL or use your distribution’s software repository system to install it.

UPDATE: SSL cert is self signed for the sourceforge link above, so I’m providing another link:

Here’s an example of the usage:

winexe -A credentials.cfg //remotehost "qwinsta /server" 

You will want to create a credentials.cfg file with the login information as so:

username=user password=pass domain=workplace 

Only supply the domain if it applies to you. It’s a best practice to not put your login credentials (especially password) on the command line. Try running cmd.exe using the example above if you want an interactive prompt. Nice thing about this approach is that you can use the output of the remote command in your Linux scripts or grep the output.

Читайте также:  Настройка прокси сервера linux mint

Источник

Удаленное выполнение команд в системе Windows из консоли Linux. Установка из исходников Winexe 1.1 + Samba 4.5 на Debian 9 Stretch.

Задался недавно вопросом, как можно из консоли Linux, подключится к удаленной машине с ОС Windows на борту и выполнить на ней какую либо команду (прим. «ipconfig») или запустить за ранее написанный скрипт (*.bat, *.ps1).

В ходе поиска решения данного вопроса, был найден инструмент Winexe, который по сути является аналогом psexec под Windows. Winexe работает в связке с Samba, поэтому последняя должна присутствовать в системе.

Из замеченных неудобств работы с Winexe, хочу отметить что для корректного отображения «кириллицы», необходимо конвертировать вывод в UTF-8 из cp866/cp1251. Так же в случае запуска на удаленной машине «cmd», «powershell» не работают клавиши курсора, «backspace» и возможен задвоенный ввод символов.

Установка будет производится на Debian 9 Stretch. В ходе установки будет использоваться Fork пакета Winexe 1.1 (https://sourceforge.net/u/mstowe/winexe/ci/v0.2/tree/), а так же версия Samba 4.5.16 из стандартные репозиториев Debian.

Подготовка системы

Обновляем систему до актуального состояния:

apt-get update && apt-get upgrade

Устанавливаем необходимые пакеты для сборки и работы «winexe»:

apt-get install gcc gcc-mingw-w64 make git python-dev pkg-config libgnutls28-dev libacl1-dev libldap2-dev samba-dev libsmbclient-dev

Для корректной сборки «winexe» делаем необходимые симлинки:

ln -s /usr/lib/x86_64-linux-gnu/samba/libcli-ldap.so.0 /usr/lib/x86_64-linux-gnu/samba/libcli-ldap-samba4.so.0 ln -s /usr/lib/x86_64-linux-gnu/samba/libdcerpc-samba.so.0 /usr/lib/x86_64-linux-gnu/samba/libdcerpc-samba-samba4.so.0 ln -s /usr/lib/x86_64-linux-gnu/samba/libsmbclient-raw.so.0 /usr/lib/x86_64-linux-gnu/samba/libsmbclient-raw-samba4.so.0 ln -s /usr/lib/x86_64-linux-gnu/samba/libsamba-debug.so.0 /usr/lib/x86_64-linux-gnu/samba/libsamba-debug-samba4.so.0

Установка Winexe

Скачиваем исходники «winexe», выполняем компиляцию и установку:

cd /opt git clone git://git.code.sf.net/u/mstowe/winexe u-mstowe-winexe cd u-mstowe-winexe/source ./waf configure build

Копируем скомпилированный «winexe» в (/usr/bin):

Синтаксис использования «winexe»:

winexe -U [Domain/]User%Password //host command

Для примера выполним на удаленной машине команду «ipconfig»:

winexe -U Администратор%Aa1234567 //192.168.1.2 'ipconfig' ⣠®©ª ¯௢®ª®« IP ¤«ퟗindows ¤ ¯⦠ Ethernet Ethernet: DNS-⤤䨪®¤ª«痢­¨힮 . . . . : ®ª «쮫© IPv6- ¤ড ª ­ « . . . : fe80::de2:f63f:7ae5:518d%6 IPv4- ¤ড. . . . . . . . . . . . : 192.168.1.2 ᪠ ¯®¤ᦢ¨ . . . . . . . . . . : 255.255.255.0 ᭮¢­®© 謮§. . . . . . . . . : 192.168.1.1

Как я и писал в начале, что в случае вывода с локалью отличной от вашей, мы получим не читаемые каракули. В примере выше, вывод был получен в кодировке «cp866», а текущая локаль моей системы «UTF-8».

Исправить это поможет пакет «luit», рассмотрим его установку и применение ниже.

Читайте также:  Most secure linux system

Установка luit

Скачиваем исходники «luit», распаковываем архив:

wget https://invisible-island.net/datafiles/release/luit.tar.gz tar -zxvf luit.tar.gz cd luit-20190106/

Выполняем сборку и установку пакета «luit»:

./configure --prefix= --datadir=/usr/share/luid make make install

Теперь перед запуском «winexe», указываем перекодировку из «cp866» в текущую:

luit -encoding cp866 winexe -U Администратор //192.168.1.2 'ipconfig' Настройка протокола IP для Windows Адаптер Ethernet Ethernet: DNS-суффикс подключения . . . . . : Локальный IPv6-адрес канала . . . : fe80::de2:f63f:7ae5:518d%6 IPv4-адрес. . . . . . . . . . . . : 192.168.1.2 Маска подсети . . . . . . . . . . : 255.255.255.0 Основной шлюз. . . . . . . . . : 192.168.1.1

Дополнительно

Работоспособность пакета «winexe» проверил на системах Windows 7, 10, 2012R2, 2019. В случае с Windows 2012R2, 2019 пришлось на них установить компонент SMB 1.0/CIFS File Sharing Support

Понравилась или оказалась полезной статья, поблагодари автора

ПОНРАВИЛАСЬ ИЛИ ОКАЗАЛАСЬ ПОЛЕЗНОЙ СТАТЬЯ, ПОБЛАГОДАРИ АВТОРА

Источник

How to access a windows server from ubuntu

Currently I can get into this windows server by typing in \\SERVERNAME. How can I do this on my linux machine? By the way i cant see the server on my windows machine I can only get there by typing that in. Thanks!

Please be a little more specific: Do you want to access your Windows server via network shares or just somehow, e.g. with Remote Desktop? Also, where do you see the Windows server? Is it in «My Network Places» on your Ubuntu machine? Please have a look on this guide.

5 Answers 5

Open a file browser, press Ctrl + L , then type smb://servername and press Enter .

In Linux there are a couple ways to either connect one time or permanently connect each time you’re logged on. In File Browser you can use the menu item File -> Connect To Server and choose Windows Share and input the path to your windows share. Or you could edit /etc/fstab with the correct file system mount point and it would reconnect or remap your share each time you logon.

Although, IMHO The best way to manage Windows / Linux shares is using Samba from the Linux environment and connect that direction each time, it will be much more friendly.

In Nautilus address bar, you type:

Replace the xs’ with the IP address of the Windows server. If you are running a firewall, you need to keep Samba ports open for outgoing connections.

Читайте также:  Ms shell dlg linux

As a System Administrator or home user, connecting to Windows Computers from Ubuntu with just file sharing is all that may be needed. Other times, there is a need to remotely access Windows Computers to perform more complex tasks. With Windows, you can easily connect to another Windows Computer running Terminal Services with a Terminal Server client. On Ubuntu, you can also access any Windows Computer using tsclient.

tsclient is a GNOME program for remotely accessing Microsoft Windows NT/2000/2003 Terminal Services and XP Remote Desktop Sharing over RDP (Remote Desktop Protocol).

With Ubuntu, tsclient is installed by default. To verify it is installed simply enter the following command in a Terminal window: dpkg –get-selections | grep tsclient If tsclient is installed you should see the output of the command as: tsclient installed

If tsclient is not installed, you can install it by executing the following command from a Terminal window: sudo apt-get install tsclient

Now that tsclient is installed, you can easily open tsclient by typing tsclient at the Terminal prompt (yes it looks exactly as the Terminal Server client on Windows!)

To quickly connect to a Windows Computer, just enter the hostname in the Computer field and click Connect at the bottom of tsclient.

enter image description here

enter image description here

Once connected you can logon to the Windows Computer as normal:

Just as you can save configuration settings on a Windows Terminal Server Client, the same can done with tsclient by setting options in the Dislpay, Local Resources, Programs, or Performance tabs. Once the settings have been configured, you can save it as a file and open it when you need to connect to the server.

Once you have saved the settings to a file, you can quickly connect to a Windows Computer from a Terminal window instead of running tsclient from the GUI. To see the tsclient command prompt options, type:

FILE an rdp format file containing options -h, –help display this help and exit -v, –version output version information and exit -x FILE launch rdesktop with options specified in FILE

Источник

Оцените статью
Adblock
detector