What API can be used to change windows account information remotely? - passwords

What API is available to change windows account passwords remotely? Assuming I have the proper credentials to change the windows accounts, I need to write software that can do so remotely.
The software will run on Linux, and so far it appears that SMB may have some functionality in this area, but I need either an API, library, code, or even the right key words to help me figure out how to search for solutions or an approach to solving this problem.
I've found Wmi client on Linux but as far as I understand there seems to be issues with it.

Try:
smbpasswd -r machine -U user.
You can use wmi-client, but on the other hand that does not work on windows 2008 server with domain controller and the password is passed in the network without encryption.

The smbpasswd command that is part of Samba allows you to change the password on remote machines. E.g.
smbpasswd -r MACHINE -U USER
You should be able to just invoke that command from your favorite programming language; the next version of Samba will have some Python APIs that probably also allow you to do this from within Python.

Related

How to make a samba server available on internet with SSH

I have a local samba server running on my raspberry pi that I use as a NAS to share files with other devices on the network. How can I use SSH to make this accessible (with a password) over the internet so I can access my files from anywhere?
The ssh related part of this question has alread good answers in this superuser question.
I strongly recommend not to use username/password authentication for external access, but restrict the access with public/private keys.
And it is not a good idea to open the samba access to the internet, so this question is not related to samba and smb.
Another solution would be to install a NAS software on your device. The benefit will be, that you can access your files with a web browser, have user management and you can enable a lot of other functions.
You can try NextCloud, OwnCloud or alternatives.

How to detect the OS and CPU architecture of a remote SSH server

I have a program that connects to a remote machine via SSH. I want to upload and run a binary on that machine. In order to do that I need to know what OS it is (I will support Linux, Mac and probably Windows), and what CPU architecture (I will probably only support x86_64, but it would be good to be able to detect others and print a sensible error, if this is possible).
It doesn't look like the SSH protocol itself provides any of this information. Is there a simple, ROBUST way to do this? With as few hacks as possible (no hairy Bash scripts!).
The best thing I can think of is to try running uname -s -m, and whatever the Windows equivalent is and parse the results.
The SSH protocol doesn't provide any information about the remote system except its protocol version. However, oftentimes vendors will include a string in the protocol string. For example, if you do nc gitlab.com 22 </dev/null | head -n 1, you can tell that GitLab runs Ubuntu.
However, not all remote systems provide this information, so for a reliable test, you'll probably need to log into the system. As mentioned, you can run uname on Unix systems, and cmd /c ver on Windows systems to find out what OS you're on. Note that the latter will not work on Windows if you log into a MinGW-based bash on Windows, since the /c will be rewritten as C:\; you'll need to double the slash or use uname there.
I'm not aware of a single command that you can invoke that will work on all systems, so you'll probably have to make multiple shell requests. You are probably better off doing this using an SSH library, since the OpenSSH binary will print any banner from the remote side whether you want it or not, and that can be confused with the output you get from the remote side.

how can I connect to the display on a google cloud machine?

I have succesfully created a machine on Google Cloud which I can access via
gcloud compute ssh my-service
however passing -X to ssh is not an option and I would like to see some plots.
Not sure what you mean with:
however passing -X to ssh is not an option and I would like to see some plots.
But you can also use the google console to connect to the SSH and get system usage graphs like CPU, Memory, Disk and Network usage.
Linux instances on GCP are server versions of the OS. There is no desktop. You can try using a VNC viewer like TigerVNC to get a similar desktop interface. You can also RDP to a windows instance to get a windows desktop. Your question is unclear. You will need to be more specific as to what you mean by "plots", "connect to the display", "-X" these terms are all very general and specific to your personal environment wherever you were.

Using saltstack ssh

Is there a difference between using salt-proxy ssh and directly salt-ssh? I'm interested because according to documentation both aimed to run remote commands without agent installation on the end machine.
You cant simply do salt-ssh on a proxy minion, for which you would have to write your own custom ssh interface to the remote system, because your proxy minion may not support doing salt-ssh.
How to choose between using salt-ssh vs salt-proxy totally depends on the type of a minion system.
As stated in the saltstack documentation - https://docs.saltstack.com/en/latest/topics/ssh/index.html and
https://docs.saltstack.com/en/latest/topics/proxyminion/index.html
For salt-ssh to be used, the remote system must have python installed - one of the criteria. For example, controlling ubuntu from centos.
As stated in the salt-proxy doc,
Proxy minions are a developing Salt feature that enables controlling
devices that, for whatever reason, cannot run a standard salt-minion.
Examples include network gear that has an API but runs a proprietary
OS, devices with limited CPU or memory, or devices that could run a
minion, but for security reasons, will not.

how I can connect remotely to a machine and use the console, without knowing its IP address?

I need to remotely access to the linux console of some machine, but i dont have that IP (and looks like it will be a dinamyc ip)
I have my PC "A", and other PC "B". I have local access to both to install and configure whatever is required, but the PC "B" will be located elsewhere.
Is ssh the best way to go? how?
Thanks!
Since Yogipriyo offered a visual solution, here is how you can access SSH without the need of a GUI. Really, it depends on what you are comfortable with; I would personally recommend it.
There are plenty of ways to utilize SSH depending on your OS (that is, "computer A's OS"):
Windows: MobaXTerm, Cygwin, and Putty are the popular ones that I've heard about. I like MobaXTerm simply because you can have multiple tabs.
Mac: Most have the ability to SSH built in via the X11 terminal. You might need to install XQuartz to enable X11 port forwarding though if this isn't working for you.
*Nix: Just get to command line; you probably know that.
Once you are there, Vim is a great editor to know. This again is a "text-based" editor and thus lends itself well to use over SSH.
Keep in mind a lot of this is personal opinion, so explore and find what makes you most productive.
For visual solution, you can use Team Viewer.
It uses it's machine ID (which assigned by the team viewer application once you install it) to connect to the machine. I used it for 2 years at my previous job as remote support and it didn't have any trouble with dynamic IP as long as you have the target's team viewer ID.
For text based, as far as I know you need the target's IP or domain, but alas it still needs static IP.