remote ssh -> access vagrant on wsl 2 error - windows

I want to access folders in vagrant(on wsl2) from VScode windows(host)
Windows
-- WSL 2
-- vagrnat
I copied 'vagrant ssh-config' into '.ssh/config'
my 'config'
Host host
HostName host
IdentityFile C:\path\to\key
User user
Host vagrant
HostName 172.31.32.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /mnt/c/Users/Mike/projects/lighthouse/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
and the output is
[13:57:11.814] Log Level: 2
[13:57:11.815] remote-ssh#0.76.1
[13:57:11.815] win32 x64
[13:57:11.819] SSH Resolver called for “ssh-remote+vagrant”, attempt 1
[13:57:11.820] “remote.SSH.useLocalServer”: false
[13:57:11.820] “remote.SSH.showLoginTerminal”: false
[13:57:11.820] “remote.SSH.remotePlatform”: {}
[13:57:11.820] “remote.SSH.path”: undefined
[13:57:11.820] “remote.SSH.configFile”: C:\Users\Mike.ssh\config
[13:57:11.820] “remote.SSH.useFlock”: true
[13:57:11.820] “remote.SSH.lockfilesInTmp”: false
[13:57:11.821] “remote.SSH.localServerDownload”: auto
[13:57:11.821] “remote.SSH.remoteServerListenOnSocket”: false
[13:57:11.821] “remote.SSH.showLoginTerminal”: false
[13:57:11.821] “remote.SSH.defaultExtensions”: []
[13:57:11.821] “remote.SSH.loglevel”: 2
[13:57:11.821] “remote.SSH.enableDynamicForwarding”: true
[13:57:11.821] “remote.SSH.enableRemoteCommand”: false
[13:57:11.821] “remote.SSH.serverPickPortsFromRange”: {}
[13:57:11.821] “remote.SSH.serverInstallPath”: {}
[13:57:11.841] SSH Resolver called for host: vagrant
[13:57:11.841] Setting up SSH remote “vagrant”
[13:57:11.861] Using commit id “c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1” and quality “stable” for server
[13:57:11.864] Install and start server if needed
[13:57:13.663] Checking ssh with “ssh -V”
[13:57:13.697] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
[13:57:13.702] Using SSH config file “C:\Users\Mike.ssh\config”
[13:57:13.702] Running script with connection command: ssh -T -D 64189 -F “C:\Users\Mike.ssh\config” vagrant bash
[13:57:13.704] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[13:57:13.921] > e]0;C:\WINDOWS\System32\cmd.exea
[13:57:13.921] Got some output, clearing connection timeout
[13:57:13.947] > vagrant#172.31.32.1: Permission denied (publickey,password).
[13:57:13.956] > 프로세스에서 없는 파이프에 쓰려고 했습니다.
[13:57:15.208] “install” terminal command done
[13:57:15.209] Install terminal quit with output: 프로세스에서 없는 파이프에 쓰려고 했습니다.
[13:57:15.209] Received install output: 프로세스에서 없는 파이프에 쓰려고 했습니다.
[13:57:15.209] Failed to parse remote port from server output
[13:57:15.210] Resolver error: Error:
at Function.Create (c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:586041)
at Object.t.handleInstallOutput (c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:584693)
at Object.t.tryInstall (c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:681846)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:644486
at async Object.t.withShowDetailsEvent (c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:647831)
at async Object.t.resolve (c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:645565)
at async c:\Users\Mike.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:722872
[13:57:15.216] ------
I tried
'ssh user#vagrant'
: user#IP addr: Permission denied (publickey,password)
remote-ssh:kill vs code server on host..
remote-ssh:uninstall vs code server on host..
checked remote.ssh:config file PATH in vscode remote-ssh settings
don't exist 'known_hosts' in .ssh folder(hidden file checked)
tried solutions from searching I found, but still stuck here.

Related

SSH permission denied for ec2 using Ansible

I am new to Ansible and was tring to figure out how to establish a ssh connection via ansible.
I have created an ec2 instance(Linux) and i have controlling node as my local machine(Ubuntu).
Now, I have generated and added key from my local to remote instance. I am also able to ssh by running ssh ec2-user#.
But, when doing the same using ansible command
ansible -i hosts all -m ping -u ec2-user
I am getting error as:
ec2-user#13.127.222.56 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ec2-user#13.127.222.56: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).",
"unreachable": true
}
My hosts file is:
[test]
13.127.222.56
Now, I am unable to figure out how to work with this further. I am missing some authentication required by ansible because this usually comes only when ssh is unable to get the key.

Vscode SSH Jump Failed with macOS

I can connect to the first server with key but cannot connet to the second server jumping with the first server. I doubt it is a bug on MacOS because I can jump to the seceond server with command line. Is there ANYONE knows what happened here?
Here is the config:
Host comp
HostName xx.xx.xxx.xxx
User xxxx
Port 22
IdentityFile ***************
Host local
HostName 127.0.0.1
Port ****
User xxxx
ProxyCommand ssh -q -x -W %h:%p comp
IdentityFile ***************
Here is the error information:
[19:55:48.660] Log Level: 2
[19:55:48.662] remote-ssh#0.55.0
[19:55:48.662] darwin x64
[19:55:48.663] SSH Resolver called for "ssh-remote+localhost", attempt 1
[19:55:48.663] SSH Resolver called for host: localhost
[19:55:48.663] Setting up SSH remote "localhost"
[19:55:48.669] Acquiring local install lock: /var/folders/5q/****************_tr0000gn/T/vscode-remote-ssh-localhost-install.lock
[19:55:48.713] Looking for existing server data file at /Users/gy/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-localhost-************************************-0.55.0/data.json
[19:55:48.742] Using commit id "***********************************" and quality "stable" for server
[19:55:48.743] Install and start server if needed
[19:55:48.779] Checking ssh with "ssh -V"
[19:55:48.854] > OpenSSH_8.1p1, LibreSSL 2.7.3
[19:55:48.860] Using SSH config file "/Users/gy/.ssh/config/vscodeconfig"
[19:55:48.861] askpass server listening on /var/folders/5q/******************_tr0000gn/T/vscode-ssh-askpass-**********************************.sock
[19:55:48.862] Spawning local server with {"ipcHandlePath":"/var/folders/5q/**************_tr0000gn/T/vscode-ssh-askpass-********************************.sock","sshCommand":"ssh","sshArgs":["-v","-T","-D","54815","-o","ConnectTimeout=15","-F","/Users/gy/.ssh/config/vscodeconfig","localhost"],"dataFilePath":"/Users/gy/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-localhost-*********************************-0.55.0/data.json"}
[19:55:48.862] Local server env: {"DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/local-server/askpass.sh","VSCODE_SSH_ASKPASS_NODE":"/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Renderer).app/Contents/MacOS/Code Helper (Renderer)","VSCODE_SSH_ASKPASS_MAIN":"/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"/var/folders/5q/********************_tr0000gn/T/vscode-ssh-askpass-**********************************.sock"}
[19:55:48.871] Spawned 34492
[19:55:48.987] > local-server> Spawned ssh: 34493
[19:55:49.008] stderr> OpenSSH_8.1p1, LibreSSL 2.7.3
[19:55:50.129] stderr> kex_exchange_identification: Connection closed by remote host
[19:55:50.131] > local-server> ssh child died, shutting down
[19:55:50.136] Local server exit: 0
[19:55:50.136] Received install output: OpenSSH_8.1p1, LibreSSL 2.7.3
kex_exchange_identification: Connection closed by remote host
[19:55:50.137] Stopped parsing output early. Remaining text: OpenSSH_8.1p1, LibreSSL 2.7.3kex_exchange_identification: Connection closed by remote host
[19:55:50.137] Failed to parse remote port from server output
[19:55:50.141] Resolver error: Error:
at Function.Create (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:1:130564)
at Object.t.handleInstallOutput (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:1:127671)
at Object.t.tryInstallWithLocalServer (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:102339)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async /Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:104310
at async Object.t.withShowDetailsEvent (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:109845)
at async /Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:100912
at async R (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:97702)
at async Object.t.resolveWithLocalServer (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:100561)
at async Object.t.resolve (/Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:107840)
at async /Users/gy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:141955
[19:55:50.143] ------
Could someone enlighten me on the reason for the problem or on a possible solution ? Thanks !
I have the similar problem.
Later it disappears after I turn off the agent server.
Maybe you can try this.

How to connect to WIndows node using openSSH and Ansible?

I am trying to connect to my windows computer using OpenSSH and Ansible.
I am able to connect using regular ssh, but when I try to connect using Ansible, I get pretty much the same error everytime I change something.
I've also tried running Ansible as root and still nothing
fatal: [IVU]: UNREACHABLE! => {"changed": false, "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo /tmp/ansible-tmp-1502794936.2073953-164132649383245 `\" && echo ansible-tmp-1502794936.2073953-164132649383245=\"` echo /tmp/ansible-tmp-1502794936.2073953-164132649383245 `\" ), exited with result 1", "unreachable": true}
I've tried to change the ssh_args in ansible.cfg to ssh_args= -o ControlMaster=no and no change to the output was made.
I've tried to change the executable in the ansible.cfg to C:/Windows/System32/cmd.exe and I got the same error
I've tried changing the remote_dir=/tmp/ and still nothing.
My ansible inventory is:
[IVU]
IVU ansible_host=**IP**
[IVU:vars]
ansible_port=22
ansible_user=**user**
ansible_ssh_pass=**pass**
ansible_ssh_private_key_file=** Keyfile **
It seems like it's failing before even running any tasks, but from the openssh logs on the windows computer I see no difference when ansible connects to it and when I ssh into it.
3724 09:27:38:720 error: Couldn't create pid file "C:\\Program Files\\OpenSSH\\sshd.pid": Permission denied
3724 09:27:41:376 Accepted publickey for **User** from **IP** port 42700 ssh2: RSA SHA256:clNmiKxygl/TLEb5Ob4lZs6JqztoQyxOsjMoHQ2HYgo
3724 09:27:58:533 Received disconnect from **IP** port 42700:11: disconnected by user
3724 09:27:58:533 Disconnected from user **User** **IP** port 42700
3360 09:28:41:398 error: Couldn't create pid file "C:\\Program Files\\OpenSSH\\sshd.pid": Permission denied
3360 09:28:41:616 Accepted publickey for **User** from **IP** port 42704 ssh2: RSA SHA256:clNmiKxygl/TLEb5Ob4lZs6JqztoQyxOsjMoHQ2HYgo
3360 09:28:41:741 Received disconnect from **IP** port 42704:11: disconnected by user
3360 09:28:41:741 Disconnected from user **User** **IP** port 42704
The 9:27 is when I'm connecting using ssh and the 9:28 is when ansible connects.
Is there something I'm missing that I need to change in order for Ansible to work with openSSH on windows?
I figured out a solution by using a reverse ssh tunnel.
I abandoned the idea of trying to use the ssh ansible module with windows since Windows simply doesn't play nicely with it unless you have the windows 10 update. I decided to use the winrm ansible module instead.
What I did is I connected the windows computer to the computer running Ansible by opening a reverse SSH tunnel by using the command:
ssh -p5983 -R 5982:localhost:5986 **my_user**#**my_ip**
For my purposes I had to port forward because my computer was on a separate vlan than the windows computer
Then in Ansible I specified that the host is localhost at port 5982.
This is about as good of a solution for when working with openssh and windows, at least until Ansible supports openssh on windows.

Vagrant hangs on NFS mounting on Ubuntu 14.04

until today my vagrant setup was working nice and smooth. But something happened and I can't find out what.
All of a sudden when I do vagrant up it hangs on mounting the NFS shared folder.
My guess is that something broke due to some updates on my host. Below are the outputs from vagrant up --debug command and the list with the latest updates from the last 2 days.
Here's the output from vagrant:
==> default: Mounting NFS shared folders...
DEBUG ssh: Checking whether SSH is ready...
DEBUG ssh: Re-using SSH connection.
INFO ssh: SSH is ready!
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: (sudo=false)
DEBUG ssh: Exit status: 0
DEBUG guest: Searching for cap: mount_nfs_folder
DEBUG guest: Checking in: ubuntu
DEBUG guest: Checking in: debian
DEBUG guest: Checking in: linux
DEBUG guest: Found cap: mount_nfs_folder in linux
INFO guest: Execute capability: mount_nfs_folder [#<Vagrant::Machine: default (VagrantPlugins::ProviderVirtualBox::Provider)>, "192.168.56.1", {"/home/vagrant"=>{:type=>:nfs, :mount_options=>["nolock,vers=3,udp,noatime,fsc,actimeo=1"], :guestpath=>"/home/vagrant", :hostpath=>"/home/stefan/NetBeansProjects/cargoplanning", :disabled=>false, :map_uid=>1000, :map_gid=>1000, :nfs_udp=>true, :nfs_version=>3, :uuid=>"2352560104", :linux__nfs_options=>["rw", "no_subtree_check", "all_squash", "anonuid=1000", "anongid=1000", "fsid=2352560104"]}}] (ubuntu)
DEBUG ssh: Checking whether SSH is ready...
DEBUG ssh: Re-using SSH connection.
INFO ssh: SSH is ready!
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: (sudo=false)
DEBUG ssh: Exit status: 0
DEBUG guest: Searching for cap: shell_expand_guest_path
DEBUG guest: Checking in: ubuntu
DEBUG guest: Checking in: debian
DEBUG guest: Checking in: linux
DEBUG guest: Found cap: shell_expand_guest_path in linux
INFO guest: Execute capability: shell_expand_guest_path [#<Vagrant::Machine: default (VagrantPlugins::ProviderVirtualBox::Provider)>, "/home/vagrant"] (ubuntu)
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: echo; printf /home/vagrant (sudo=false)
DEBUG ssh: Exit status: 0
DEBUG ssh: stdout:
/home/vagrant
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: mkdir -p /home/vagrant (sudo=true)
DEBUG ssh: stderr: stdin: is not a tty
DEBUG ssh: Exit status: 0
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: mount -o 'nolock,vers=3,udp,noatime,fsc,actimeo=1' 192.168.56.1:'/home/stefan/NetBeansProjects/cargoplanning' /home/vagrant (sudo=true)
DEBUG ssh: stderr: stdin: is not a tty
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
Try either to restart nfs service (sudo systemctl restart nfs-server.service for me in Arch) or to remove Vagrant entries from /etc/exports (they are surrounded with #VAGRANT-BEGIN: ... #VAGRANT-END: comments) and then to restart the service.
The problem was the udp protocol.
I removed udp from VagrantFile config line:
:mount_options => ['nolock,vers=3,udp,noatime,fsc,actimeo=1']
Also, udp is not recommended even if it's faster. https://github.com/mitchellh/vagrant/issues/2304
For anyone else still looking around and on 18.04, I found the culprit in my case.
It looks like in my case nfs-server package was missing even though nfs-kernel-server and nfs-common were installed, I installed nfs-server and vagrant up worked without an issue. Vagrant 2.0.3 and Virtualbox build 5.2.18_Ubuntu r123745

Getting permission denied when pushing to git vps server

I installed git for windows, creating my ssh key and uploaded the public to my server.
I have this working on my Mac, trying to get it working on my windows machine now.
I did a :
chmod 700 ~/.ssh/
chmod 600 ~/.ssh/*
Here is an image of me doing a ssh -v gitserveralias
I have a config file that has the gitserveralias and port etc.
I tried clearing out the known hosts file also.
My config looks like:
Host serveralias
User xxx
Hostname 123.234.452.232
Port 22222
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive true
IdentitiesOnly yes
PreferredAuthentications publickey
Again I have my setup working fine on my Mac.
Two things to check:
Do you have "PubkeyAuthentication yes" in sshd_config on your server? Try setting it.
Is there an offending key in .ssh/known_hosts? Try removing this file.

Resources