Is there a way to sync ssh directory keys across multiple devices? - ssh

I have two windows and one Ubuntu devices that I regularly work with, and I was wondering if there is a way for me to sync the ssh directory for each of the device so that they all have the same ssh key, config, and authorized_key? For windows I'm using the Ubuntu terminal from Microsoft store.

I personally don't recommend this, but it has been answered here. See the answer by #trisweb about scp. Hope this helps

Related

How to remote SSH into a MacOS or Linux terminal using the Termius app?

I have been playing with the Termius app on Android running downloaded shell scripts that I wrote, catting files and snooping inside my device's directories; among other goofy stuff.
I have seen in some tutorials that I can remote SSH into my computer's terminal and run commands into my Android's Termius as if I'm typing on my computer's keyboard.
Having attempted these instructions myself, I've found they're no good (IMHO) and I couldn't make them work. Also, these tutorials have no good explanation for how I am actually SSHing using the Termius app.
The question is: How do I make it work and how does it work?
You would need to:
generate a key on Termius (and export it)
add that key to your Mac or Linux remote user ~/.ssh/authorized_keys
connect to the remote computer using ssh remoteUser#remoteIP
That assume you have an ssh daemon listening on that remote computer.

Can I run one WSL2 virtual machine instance on two system?

I'm new to the WSL2 and wondering if it's possible to run the same WSL2 ubuntu instance on both my desktop and laptop.
Now I am able to use wsl --export and wsl --import method to save and load the system to/from my portable hard drive. But these methods takes a long time.
I notice that wsl --import load a file named ext4.vhdx. Is there a way to load straightly from this file?
Update v2.0:
I was able to get a workaround and it works great.
Thanks to Booting from vhdx here, I was able to load straightly from my vhdx file on my portable hard disk. Windows track down its subsystem with regedit, So we can write our own(p.s: make sure to get BasePath right, it starts with "\\\\?", or you will not be able to access the subsystem' filesystem on your host system.):
Windows Registry Editor Version 5.00
[HKEY_USERS\【your SID here】\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\{【UUID here】}]
"State"=dword:00000001
"DistributionName"="distribution name"
"Version"=dword:00000002
"BasePath"="vhdx folder path" 【 e.g. "\\\\?\\E:\\S061\\WSL\\ubuntu-20"】
"Flags"=dword:0000000f
"DefaultUid"=dword:000003e8
I suppose the best way to do this would be to store ext4.vhd on a network storage device accessible to both devices.
I have previosly mentioned how to move ext4.vhd. You can check that out here
Basically you need to export from one machine and import it while making sure the vhd file is configured for wsl to access from the network storage
Since this should *officially* not supported expect some performance hits
Another way would be to run WSL on one computer and ssh/remote desktop to it from another device on the network
I'm of the strong belief that sharing the same ext4 vhd between two VM's simultaneously would be a bad idea. See this and this Unix & Linux StackExchange, including the part about ...
note that sharing LVs/partitions on a single disk between the servers at the same time is NOT very safe. You should only access whole disks from any of the servers at one time.
However, as dopewind's answer mentioned, you can access the WSL instance on one computer (probably the desktop) from another (e.g. the laptop). There are several techniques you can use:
If you have Windows 10 Professional or Enterprise on one of the computers, you can enable Remote Desktop, which allows you to access pretty much everything on one computer from another. RDP ("Remote Desktop Protocol") even works from other devices such as an iPad or Android tablet (or even a phone, although that's a bit of a small screen for a "desktop"). That said, there are better, more idiomatic solutions for WSL ...
You could enable SSH server on the Windows 10 computer with the WSL instance (instructions). This may sound counterintuitive to some people, since Linux itself running in the WSL instance also includes an SSH server (by default). But by SSH'ing from (for example) your laptop into your desktop's Windows 10, you can then launch any WSL instance you have installed (if you choose to install more than one) via wsl -d <distroName>. You also avoid a lot of the network unpleasantness in the next option ...
You could, as mentioned above, enable SSH on the WSL instance (usually something like sudo service ssh start) and then ssh directly into it. However, note that WSL2 instances are NAT'd, so there's a whole lot more hackery that you have to do to get access to the network interface. There's a whole huge thread on the WSL Github about it. Personally, I'd recommend the "Windows SSH Server" option mentioned about to start out with, then you can worry about direct SSH access later if you need it.
Side note: Even though I have SSH enabled on my WSL instances, I still use Windows SSH to proxy to them, to avoid these networking issues.

monitor local file excution/access history triggered by a remote server

My question is somewhat similar to this, but a little different from that:
I want to monitor the file execution/access history on a CentOS 7.2 machine. I know that a remote server is calling some files on my local machine through SSH in order to finish some tasks, so I want to find out what files on my local machine that the server is calling.
I tried to use the terminal command:
ls -lu
but it didn't show any invocation history that was triggered by the remote server through SSH. Later I learned about inotify. But I also heard that it's not available on Centos 7. Is it true? If not, how should I use it? I didn't find a dirty and quick inotify tutorial for centos. Is there any system logs that records this type of information? Any other ideas on how to achieve my goal?

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.

dokan sshfs for windows

I read an article here about dokan sshfs for windows. I want to ask if you know similar software (free or not) in order to access windows partitions from windows. Samba is a always an answer, however I am seeking for something more secure.
You can use the Dokan SSHFS client with the OpenSSH server for Windows, you can configure OpenSSH like you would on UNIX, then use the Dokan SSH client to connect remotely, just as you would do on UNIX with sshfs.
When you say Samba, so you mean SMB? Samba is the *NIX client/server for SMB.
SSHFS for accessing Windows partitions from Windows ? Did you by any chance mean Linux partitions from windows ?
If windows-windows, then sorry, no. sshfs is a Linux/Unix feature, and microsoft does all it can to NOT make it work on Windows (after all, that would allow to easily and securely migrate from Windows to Linux). On Windows, you use WebDAV to accomplish similar things, needless to say WebDAV is way more insecure than sshfs.
If you meant accessing remote Linux partitions from Windows, then I had the same problem before:
Dokan doesn't work, at least not on Vista x64. (epic bluescreen crash)
The java sshfs explorer on sourceforge doesn't work, either.
Microsoft's services for unix (including sshfs) are only available on Vista 'Ultimate', not on < Ultimate, like my Vista business for example.
There are some commercial solutions, but first, they are way overpriced, and second, I wouldn't trust them, since they don't offer evaluation.
My solution was to install VirtualBox on Windows, and install an Ubuntu guest on it, mounting the host's C drive. You need to set the VirtualBox network adapter to bridged mode to make sshfs work with virtualization. I'm sorry, but so far that's the only free solution that really works...
imdisk driver, see if http://www.ltr-data.se/opencode.html helps.
From the documentation
It is even possible to boot a machine
with NTFS partitions using a Unix
Live-CD and use the included devio
tool to let ImDisk on another computer
running Windows on the network mount
the NTFS partition on the machine you
booted with the Unix Live-CD. This way
you can recover information and even
run chkdsk on drives on machines where
Windows does not boot.
I've been using Win SSHFS for awhile, is this what you're looking for?
https://github.com/Foreveryone-cz/win-sshfs/
It runs on top of Dokany