Ansible SSH Key Setup - ssh

I'm dipping my toes into Ansible and I'm having trouble configuring SSH keys.
I currently have two Ubuntu 14.04 VMs running and present in the Ansible hosts file.
I also have an extra VM which is being used for Ansible management.
I have created an SSH key on the management machine and 'ssh-copy-id' them to both of the Ubuntu 14.04 VMs.
Based on watching videos and following tutorials of Ansible configuration, I should now be able to run 'ansible instancegroupname -m ping' sequentially on both of the machines without having to enter a password.
However when running that command on the management VM, I am prompted to enter the SSH passphrase for the management VM itself, something I have not seen in the tutorial videos. It just seems to work for them?
Thanks guys.

This was solved by adding the ssh-key to the ssh-agent.

Related

Does replit uses ssh?

Replit's terminal provides a lot of features that are very similar to any Linux terminal. At first, I thought the site was using SSH to link a remote terminal to the website but when I ran the following command service ssh status, then the output was
* sshd is not running. This indicates that the site is not using SSH to link the terminal.
Does this mean the developers have created a custom terminal for their website or is there a way to show this output for remote users for security purposes?

SSH'ing from windows 10 into wsl2 ubuntu

I am fairly new to this business and I fail to understand how to SSH from my win10 machine into my installed wsl2 ubuntu 20.4
Basically, I followed this tutorial, But I keep getting the following errors:
when I try to SSH using the public port (using curl ifconfig.me) gives me the error "connection timed out"
when I try to SSH using the private port (using ip route get 1.2.3.4 | awk '{print $7}') it gives me the error "Permission denied"
at some point I got the error "sshd: no hostkeys available -- exiting" so I followed this fix but then I got the errors mentioned before. Should I delete any from the /etc/ssh folder?
The end-goal is ssh'ing through vs-code, but I guess once I could do it from powershell, it's the same from vs-code.
It appears that you need to enter /etc/ssh/sshd_config (with sudo permissions) and change the following lines:
ChallengeResponseAuthentication yes
PasswordAuthentication yes
Since you seem to have fixed your issue with ssh, let me propose that your ultimate goal ("ssh into WSL from VSCode) might be better accomplished using Microsoft's "Remote Development" extension pack, which includes several extensions. While it sounds like you are considering using the "Remote - SSH" extension, you can also use the "Remote - WSL" extension directly.
After installing either the extension pack or the WSL extension directly, just open your WSL instance, cd to the directory with your code and then code . (including the period). This will open VSCode and install a shim into the WSL instance which will allow communication between the two.
See the docs from Microsoft for more detail.
Also, on the topic of your original question, you said that you edited sshd_config to permit password authentication (I don't think the ChallengeResponseAuthentication change was necessary). That's one way to go, but ultimately I'd recommend generating an SSH key pair, copying the private key to something like C:\Users\yourid\.ssh\id_rsa and using that instead of a password login.
And you mentioned in your original question that you were unable to access SSH on the public port. This is because WSL2 does not do NAT, so it also won't be accessible from a second computer without (a lot of) additional effort (manual port-forwarding from Windows to WSL, which will have to be reset on reboot since the WSL interface address will change).
As you've discovered, the WSL interface address will work, but remember that it will change on each reboot of Windows (technically, I think, any time the WSL subsystem is shut down and restarted). IMHO, you're better off using 127.0.0.1 or localhost.
But really, my preferred method of accessing WSL remotely is to install OpenSSH on Windows 10, port 22. Then you can simply do something like ssh -t windowsusername#mycomputername.local wsl to get access to the WSL instance. You can even do this when you have multiple WSL instances on your machine with ssh -t windowsusername#mycomputername.local wsl -d WSLInstanceName.
If you use this technique, of course, and you still want to run an SSH server in a WSL instance, you'll need to use a different port. But I really think you should do this anyways when running SSH under WSL. Otherwise, you are likely to spin up a second WSL instance at some point and run into port conflicts anyway.
The downside is that the Windows OpenSSH -> WSL hack won't allow you to run things like VSCode through SSH, but it does provide super-simple access to WSL through SSH, and works remotely (if you ever need that) as well.

scp between two virtual machines in virtualbox

I am currently running two virtual machines using virtualbox, one is an ubuntu 14.04 and the other one is a centOS7 on a redhat (64 bit) system. What I am trying to do is to write a shell script that simply copies a file to my centOS7 machine, I am running this script in my ubuntu machine and the file is on the Ubuntu virtual hard drive. I have so far set the IP in my CentOS7 to be static to xxx.xxx.xxx and the script is simply written as scp file_to_move username#xxx.xxx.xxx:/here/.
but it does not work I wonder is there something I need to configure in my virtualbox or is the script plain wrong?
1) Have you installed ssh-server on your ubuntu machine
2) Have you generated the public/private e.g. RSA keys pair to enable the batch usage of ssh client in your script
3) Have you properly configured the VirtualBox eth cards so that both your machines are in the same network (machines can ping one another)
...
As you can see there may be a lot of reasons why you cannot copy files between your machines and without additional environment information it is hard to say what is causing the issue in your case.

Ubuntu on VirtualBox and Rails server

I have Windows 7. Installed VirtualBox and Ubuntu 11.04 as guest OS.
Networking is done by NAT.
Everything is fine: I have internet on Ubuntu.
I can access Windows from Ubuntu by its ip.
But i can't access Ubuntu by it's ip which is shown by ifconfig.
I run rails on Ubuntu.
How can I solve this problem: connect to Ubuntu/Rails server on ort 3000 from my Windows?
By default, VirtualBox's NAT allows the virtual machine to access the Internet ; but doesn't allow the physical machine to access the Virtual one.
The simplest solution would be to use another networking setting than NAT, for your Virtual Machine -- for instance, bridge should work fine (your VM would be visible on your network, though).
Another solution would be to use port forwarding ; about that, this article might help : Howto Access via ssh a Virtualbox Guest machine.
I used to struggle with configuring a similar setup until I found Vagrant. Vagrant makes it very simple to setup, connect to and work with a Linux virtual machine. After Vagrant is configured you can just type vagrant ssh to enter the virtual machine and your account has automatic sudo rights and everything works as expected - you don't even have to deal with logging into the vm. The initial setup for ssh does look to be a little more work under Windows though as you need to configure Putty before you can connect.
There is a simple configuration file in Vagrant that you use to specify which ports from the VM you want forwarded to your machine using a syntax like:
config.vm.forward_port("rails", 80, 3000)
config.vm.forward_port("tomcat", 8000, 8080)
and everything is taken care of. Details are here
If, for example, you are using Rails and you start vagrant with the command vagrant up in your Rails project directory than that directory is available on the VM. Since it is the same shared directory between machines, any changes you make in your Rails project directory on your machine using your regular editor is seen on the VM also. This makes testing in other environments very easy.
Instructions for setting Vagrant up with Windows are here and a RailsCast about it is here. Note that Vagrant has nothing to do directly with Rails - you can use it for setup of any virtual machine environment you need.
In short, you can't.
It is a local host not a public domain therefore not publicly accessible outside of your virtualbox environment.
Maybe someone has a clever hack for this but why would you want to do this in the first place?
Your solution is to either use firefox to browse to your localhost within your virtualbox linux session or develop on windows.
Personally I work the other way round I run Ubuntu 11.04 and I have virtualbox installations of xp, 2,000, me, vista and 7 so I can test in different environments. Inevitably I end up sharing my project folder from Ubuntu so that I can run the project in whatever OS I am testing for.

Debian wheezy Linux guest environment not available

Since yesterday I can't connect through ssh to all of my Debian wheezy instances on my google cloud. I can connect only through the web console. When the web console tries to negotiate the session, there's a message telling me to update the Linux guest environment. But for wheezy, there is no Linux guest environment package.
Do you have any idea to resolve this issue ?
Debian 7 images were deprecated a while a go and as there are no update packages for the Guest Environment, the best approach would be to migrate to Debian 8 or 9.
To access your VMs you might try one of the following options:
1) According to this public issue the old guest environment still work with deprecated keys. If you have an SSH client configured with an old private key, you might still have access to your VMs through it.
2) Accessing the VM via the serial console
3) Mounting, as secondary, the original disk or a copy of it in a VM you do have access to. The steps are very similar to the section “Inspect an instance without shutting it down” on this document". That would allow you to recover your data.