Related
I'm continuing my adventure with Xamarin.
I'm developing an Xamarin Forms application with a Portable Class Libraries (PCL).
I have compiled and debugged my application by Android, but now, I'm interested to run the application in iOS to test in this platform.
I have a problem with the connection between my PC and the Mac.
I have a PC (Windows 8.1) with Visual Studio Community 2015 with Xamarin tools installed.
In my Mac Mini, I have installed OS X (v10.11.3), XCode (v7.2) and Xamarin Studio. I have logged in with my Xamarin account.
In the two machines I have the same Xamarin version.
I have followed the Xamarin walkthrough.
On Visual Studio I open the Xamarin Mac Agent. It finds my Mac Mini. Then it asks me the Mac credentials (user and password).
The login works at this point.
Then, in the solution, I set the iOS project as the startup project. I clean the solution, I build again and start the compile/debug process (F5).
In this point, the output retrieves a message:
1> Connecting to Mac server Macs-Mac-mini.local...
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(54,5): warning : Could not authenticate the user using the existing ssh keys
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(54,5): error : Unable to connect to Address='Macs-Mac-mini.local' with User='macmini
I have used Putty (SSH Client) to check with my user/password if I'm able to connect to Mac, and I have had success.
Into /Users/macmini2/.ssh/authorized_keys file (Mac machine) each time that I use the Xamarin Mac Agent, Visual Studio adds a new key entry (it adds the same repeated).
I see that perhaps the problem is related with ssh keys.
Why I have this problem? What am I doing wrong?
A thing that I have tested was openning the Xamarin project directly in Mac with Xamarin Studio, build it and run the simulator. It works.
I have seen other similar question, but I think that it doesn't have the same problem.
EDIT:
More specific information about the error when I try to compile/debug:
Could not authenticate the user using the existing ssh keys
Xamarin.Messaging.VisualStudio.MessagingAuthenticationException: Could not authenticate the user using the existing ssh keys ---> Renci.SshNet.Common.SshAuthenticationException: Permission denied (publickey).
en Renci.SshNet.ClientAuthentication.Authenticate(IConnectionInfoInternal connectionInfo, ISession session)
en Renci.SshNet.ConnectionInfo.Authenticate(ISession session)
en Renci.SshNet.Session.Connect()
en Renci.SshNet.BaseClient.Connect()
en Xamarin.Messaging.VisualStudio.MessagingService.<ConnectAsync>d__70.MoveNext()
--- Fin del seguimiento de la pila de la excepción interna ---
EDIT 2:
I have revised the troubleshooting Xamarin page, specifically that it says "Unable to authenticate with SSH keys. Please try to log in with credentials first".
I have run:
chmod og-w "$HOME"
grep sshd /var/log/system.log > "$HOME/Desktop/sshd.log"
cd Desktop
cat sshd.log
And the content of the file is:
Apr 18 09:23:28 Macs-Mac-mini sshd[769]: Authentication refused: bad ownership or modes for directory /Users/macmini2/.ssh
Apr 18 09:25:27 Macs-Mac-mini com.apple.xpc.launchd[1] (com.openssh.sshd.EE9A94ED-????-....-????-77254934B300[769]): Service exited with abnormal code: 1
Apr 18 09:59:39 Macs-Mac-mini sshd[1036]: Accepted keyboard-interactive/pam for macmini2 from 192.168.54.14 port 60413 ssh2
Apr 18 09:59:39 Macs-Mac-mini sshd: macmini2 [priv][1036]: USER_PROCESS: 1040 ttys000
But now I don't know what I have to do to solve it.
You have to try delete everything from
%localappdata%\Xamarin\MonoTouch
It helped me, I had the same (or similar) problem today.
I have found the solution about my problem. I have done the following steps:
In my Windows: I have removed the content from "%localappdata%\Xamarin\MonoTouch."
In Mac terminal: Remove the authorized_keys Mac file ("rm /Users/macmini2/.ssh/authorized_keys" in my case)
In Mac terminal: chmod g-w /Users/macmini2/
In Mac terminal: chmod 700 /Users/macmini2/.ssh/
In Mac terminal: Create a empty file: /Users/macmini2/.ssh/authorized_keys (with vim, for example)
In Mac terminal: chmod 600 /Users/macmini2/.ssh/authorized_keys
On Visual Studio: Login with Xamarin Mac Agent
On Visual Studio: Run the application with [Debug] - [iPhoneSimulator] - [iPhone 5 iOS 8.1]
And finally, the simulator runs on Mac computer.
This link helped me.
Xamarin has a Troubleshooting page with large focus on SSH issues:
Connection Troubleshooting
Specifically these two:
Log File Location
Mac – ~/Library/Logs/Xamarin-[MAJOR.MINOR]
Windows – %LOCALAPPDATA%\Xamarin\Logs
The log files can be located by browsing to Help > Xamarin > Zip Logs in Visual Studio.
"Unable to authenticate with SSH keys. Please try to log in with credentials first"
Known cause:
SSH security restriction – This message most often means that one of the files or directories in the fully qualified path of $HOME/.ssh/authorized_keys on the Mac has write permissions enabled for other or group members. Common fix: Run chmod og-w "$HOME" in a Terminal command prompt on the Mac. For details about which particular file or directory is causing the problem, run grep sshd /var/log/system.log > "$HOME/Desktop/sshd.log" in Terminal, and then open the sshd.log file from your Desktop and look for "Authentication refused: bad ownership or modes".
Furthermore there is this section, which does not directly match the error you are seeing but goes into some detail on SSH configuration and diagnosis:
"Couldn't connect to MacBuildHost.local. Please try again."
Reported causes:
Bug – A few users have seen this error message when attempting to log in to the build host using an Active Directory domain user account.
Bug – Some users have seen this error when attempting to connect to the build host by double-clicking the name of the Mac in the connection dialog. Possible workaround: Manually add the Mac using the IP address.
Bug #35971 – Some users have run across this error when using a wireless network connection between the Mac build host and Windows. Possible workaround: Move both computers to a wired network connection.
Bug #36642 – On Xamarin 4.0, this message will appear anytime the $HOME/.bashrc file on the Mac contains an error. (Starting with Xamarin 4.1, errors in the .bashrc file will no longer affect the connection process.) Workaround: Move the .bashrc file to a backup location (or delete it if you know you don't need it).
Limitation – This error can appear if the Mac build host is connected to a router that has no access to the internet (or if the Mac is using a DNS server that times out when asked for the reverse-DNS lookup of the Windows computer). Visual Studio will take roughly 30 seconds to retrieve the SSH fingerprint and eventually fail to connect.
Possible workaround: Add "UseDNS no" to the sshd_config file. Be sure to read about this SSH setting before changing it. See for example http://unix.stackexchange.com/questions/56941/what-is-the-point-of-sshd-usedns-option.
The following steps describe one way to change the setting. You will need to be logged in to an administrator account on the Mac to complete the steps.
Confirm the location of the sshd_config file by running ls /etc/ssh/sshd_config and ls /etc/sshd_config in a Terminal command prompt. For all of the remaining steps, be sure to use the location that does not return "No such file or directory".
Run cp /etc/ssh/sshd_config "$HOME/Desktop/" in Terminal to copy the file to your desktop.
Open the file from your Desktop in a text editor. For example you can run open -a TextEdit "$HOME/Desktop/sshd_config" in Terminal.
Add the following line at the bottom of the file:
UseDNS no
Remove any lines that say UseDNS yes to make sure the new setting takes effect.
Save the file.
Run sudo cp "$HOME/Desktop/sshd_config" /etc/ssh/sshd_config in Terminal to copy the edited file back into place. Enter your password if prompted.
Disable and re-enable Remote Login under System Preferences > Sharing > Remote Login to restart the SSH server.
I have just solved this problem!
It was nonsense.
To connect Visual Studio Xamarin project and simulate that on Mac when you get:
Couldn't connect to computername.local please try again later.
What you need to do next:
Follow the solution from xamarin community about mac connection
after this point if everything OK, you will connect, but if no..
Install XAMARIN STUDIO on MAC. After installation start XAMARIN studio, create your own app and run with simulator
Close app and try to connect again from Windows computer.
At this point you will make synchronization and that's all.
Problem solved! I hope this will be useful for somebody.
For me helped next solution:
1)On Windows open Visual Studio:
Tools=>Options=>Xamarin=>Other and click in Check Now
2)On Mac open Xamarin Studio Community (https://www.xamarin.com/download)
Xamarin Studio Community=>Check for Updates... (and download last one)
After updates all works fine.
I tried a few of the solutions mentioned here and had no success.
However (though not ideal) if I run Visual Studio in Administrator Mode I can successfully connect. Could be a work around for some until a better solution is found.
This is not perfect solution, but made success in my case
Your mac account should not contain any special characters- This is limitation in connection to mac from windows
company-mac1 --- wrong
comapanymac1 --- Correct
For what it's worth I just solved this issue by checking the logs as noted above and in the Xamarin Troubleshooting docs. It turned out to be mismatched iOS versions. Once I updated the Mac version it worked.
In my case, i installed mono sdk on my mac it solve the problem
http://www.mono-project.com/download/#download-mac
Ignored the agent that Visual Studio wizard showed. Something about the Mac computer name VS didn't understand.
I did 'Add Mac', used the IP address, then it connected. That was annoying.
Did you turn on remote login and that is the user/login that is currently logged into the machine? Also, have you tried connecting directly to the IP address instead of the DNS name?
I am on a client's network (different domain than mine) and my VS would never connect via the computer name. I always had to type in the IP address. Also, watch the out put for "Xamarin" in the Output panel/window and see if it gives any more helpful information.
I had this problem recently (despite having enabled Sharing on the OSX host and checking firewall) and it turned out that both OSX Machine and Windows Machine needed the exact same version of Xamarin.iOS and a restart.
Updating both, restarting both, solved the problem for me.
I think what fixed it for me was opening git bash then running ssh onto the mac box. After saying Y to trusting credentials it worked.
In my case I could not connect to XCode because "XCode" file wasn't located at the "Application" folder on MacOS. When the "XCode" app was moved to "Application" folder, I had connect.
Update Visual Studion on Mac and:
1) Delete on Mac - all files in .ssh (rm *)
2) Delete on Mac the folder .ssh
3) On Windows, generate your ssh key and transfer to MAC - for that Open Windows PowerShell and execute the follow commands:
[generate the key]
PS>ssh-keygen -t rsa -b 4096
[define the remote host variable]
PS>$REMOTEHOST="name_of_mac_user#ip_mac_machine"
[send the key to mac machine]
PS>scp "$env:USERPROFILE\.ssh\id_rsa.pub" "${REMOTEHOST}:~/tmp.pub"
[copy the key tmb.pub to authorized_keys file and set the permissions]
PS>ssh "$REMOTEHOST" "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp.pub >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && rm -f ~/tmp.pub"
4) check on mac .ssh folder if the authorized_keys file is correct:
tail ./authorized_keys
5) check the permission for authorized_keys (-rw-------)
ls -al ./authorized_keys
I created an SSH session into my localhost through PuTTY. I am running OpenBSD server on the localhost which is a Windows 7 machine. The login was successful. Now I want to start programs in the PuTTY shell for example notepad.exe. I changed the directory to c:\windows\system32. The command start notepad runs without error but I don't see any window.
Is the notepad running in the background without a windows. If yes, how to make the window visible??
Yes, it's quite likely the Notepad is run in an invisible Windows session on the server. Note that it does not make a difference in this case that the server is the local machine.
If you hoped for the window to appear on the "local" machine magically, you are out of luck.
Generally, it's possible to run a GUI application on remote machine and see the GUI locally. On Unix it's quite common. Typically X Window is used for that.
But Windows GUI applications cannot be "tunneled" via SSH session to a local machine.
When I try downloading a file from my server onto my computer, it actually downloads the file onto the server.
(Note I am already SSH'd into my server before typing this command. I've watched tutorials on YouTube and people are using their terminal without SSHing into any particular server, however I don't think I can do this with PuTTY on Windows?)
scp -r -P2222 kwazy#mywebsite.example:/home2/kwazy/www/utrecht-connected.nl ~/Desktop/
The problem is that I am specifying the location to download the file as only ~/Desktop/
This creates a folder called Desktop in my server, instead of copying the files onto my local desktop.
I am able to use this command on Linux.
I have successfully download the folder onto my desktop:
I still need insight onto how I can do this on a Windows machine.
There's no way to initiate a file transfer back to/from local Windows from a SSH session opened in PuTTY window.
Though PuTTY supports connection-sharing.
While you still need to run a compatible file transfer client (pscp or psftp), no new login is required, it automatically (if enabled) makes use of an existing PuTTY session.
To enable the sharing see:
Sharing an SSH connection between PuTTY tools.
Even without connection-sharing, you can still use the psftp or pscp from Windows command line.
See How to use PSCP to copy file from Unix machine to Windows machine ...?
Note that the scp is OpenSSH program. It's primarily *nix program, but you can run it via Windows Subsystem for Linux or get a Windows build from Win32-OpenSSH (it is already built-in in the recent versions of Windows 10 and in Windows 11).
If you really want to download the files to a local desktop, you have to specify a target path as %USERPROFILE%\Desktop (what typically resolves to a path like C:\Users\username\Desktop).
Alternative way is to use WinSCP, a GUI SFTP/SCP client. While you browse the remote site, you can anytime open SSH terminal to the same site using Open in PuTTY command.
See Opening Session in PuTTY.
With an additional setup, you can even make PuTTY automatically navigate to the same directory you are browsing with WinSCP.
See Opening PuTTY in the same directory.
(I'm the author of WinSCP)
try this scp -r -P2222 kwazy#mywebsite.example:/home2/kwazy/www/utrecht-connected.nl /Desktop
Another easier option if you're going to be pulling files left and right is to just use an SFTP client like WinSCP. Then you're not typing out 100 characters every time you want to pull something, just drag and drop.
Just noticed /Desktop probably isn't where you're looking to download the file to. Should be something like C:\Users\you\Desktop
OpenSSH has been added to Windows as of autumn 2018, and is included in Windows 10 and Windows Server 2019.
So you can use it in command prompt or power shell like bellow.
C:\Users\Parsa>scp parsa#192.168.100.11:/etc/cassandra/cassandra.yaml F:\Temporary
parsa#192.168.100.11's password:
cassandra.yaml 100% 66KB 71.3KB/s 00:00
C:\Users\Parsa>
(I know this question is pretty old now but this can be helpful for newcomers to this question)
if you install git with git bash, you get SCP available on windows.
You can use WinSCP : https://winscp.net/eng/download.php
Or MobaXterm : https://mobaxterm.mobatek.net/download.html
It feels like FTP client. Also I don't remember setting up anything on my machine for this. It just fresh install and install SSH server (IDK if it matters though).
For MobaXterm :
If your server have a http service you can compress your directory and download the compressed file.
Compress:
tar -zcvf archive-name.tar.gz -C directory-name .
Download throught your browser:
http://the-server-ip/archive-name.tar.gz
If you don't have direct access to the server ip, do a ssh tunnel throught putty, and forward the 80 port in some local port, and you can download the file.
You can use the WinSPC program. Its access to any server is pretty easy. The program gives its guide too. I hope it's helpfull.
If you need something with GUI you can use FileZilla. it support SFTP.
It's perfectly working with ssh and you can even edit files and it will automatically upload the changes.
I'd like to launch a mac application (.app) directly from a web server from a shell script.
I can launch shell scripts directly from the server using curl:
curl -s http://myserver/myscript.sh | sh
I can open a local mac app with open:
open /Applications/Myapp.app
But if I try and open an app directly from the web server using open, it just tries to open my application in a browser window (the default for open):
open http://myserver/myapp.app
Can anyone think of a way (with curl or open or anything else!) that I can open an app remotely without having to first download it locally?
I program with eclipse and sometimes use GUI text editors like SciTE or vim. However, I'm at a point in a project that requires me to edit files over a ssh connection in a 80 column SSH window.
Since I have to (* shiver*) sudo vim before I can open the file I'm not sure how to open the file in an editor outside the terminal (that would allow me to see the text wider than 80 columns). If the command line was larger then I guess using straight vim wouldn't be a problem.
I'm at a loss of how to deal with this situation and how I could turn this nightmare into a manageable coding environment.
Maybe you should simply mount the remote filesystem to your local machine and then use whatever editor you like. If running a Debian derivative, install sshfs
sudo apt-get install sshfs
and then mount the remote filesystem ( issue on your local machine )
mkdir ~/remote_code
sshfs $USER#remote.example.com:/home/$USER/code ~/remote_code
Once this is done you can access the code in ~/remote_code w/ any of your GUI tools and without the bandwidth overhead of using ssh -X (however you still need a good connection w/ a low ping time).
PS: When using ssh I can make the terminal as wide as it fits my screen and then use its full width, so I fear I don't completely understand your issue.
WinSCP is a SSH client ftp-like. The default editor is primitive but can be change.
There are various options.
You can make the terminal larger. ;)
If you have a graphical environment installed on the machine you are ssh'ing into, you can login with ssh -X (or xdeep-putty if you are on Windows) to enable window forwarding. You can then run your favourite editor on the remote machine, whose graphical output is forwarded.
Finally, you can mount the ssh connection into your file system, using for example fuse (similar options might exist for non-linux operating systems). That allows you to access any file on the remote machine as if it were in your filesystem, with your favourite editor, locally.
I'm not 100% sure if this works for files owned by root, but if your desktop is KDE & your remote system is Linux (or pretty much any form of *nix), you can get konqueror to access the remote machine using the "fish://" protocol. From there you can open the file from konqueror using kate, or your preferred editor, and konqueror will take care of copying the file to your local machine and copying it back when you save.
Failing which the X11 forward is a good option, but X11 over ssh to remote sites can be slow. "ssh -X -C" compresses the data stream and can give better performance.
Notepad ++ has a plugin for editing files remotely over ssh. I've used it before, but I definitely prefer Kate on KDE using the fish protocol.
http://www.inmotionhosting.com/support/website/ftp-client-setup/connect-ftp-notepad-plus
Forward your X11 session to your terminal.
http://dragonwall.net/xdeep-putty.html
This probably belongs on superuser.com.
You might try the Komodo editor. It has a feature to load a 'remote file' over ssh. It's really convenient.
Emacs and ange-ftp.
If you're on Ubuntu, go to Nautilus (file explorer), connect to server (adding sftp:// to the hostname), then voila! You can easily launch gedit to edit your files now.
On Windows, you can use MobaXterm ( http://mobaxterm.mobatek.net ): it has a built-in SSH client with a very useful "SFTP browser".
As soon as you connect to your remote server using SSH, you will see your remote files displayed in this graphical SFTP browser. Just double-click on your files and you will be able to edit them directly on your remote server through SFTP.
I use Cyberduck and Sublime Text 2
FileZilla did the trick for me. Notepad++ can be used with it which is awesome.
If you using windows, try Editplus. It's not free but allows you to open files directly over scp. Custom syntax files are coming really handy, too.
Recent versions of ultraedit do exactly what the OP is asking for elegantly (IDM software, v10 and up support SSH iirc). I do most of my coding remotely like that, been using it for years, works great with no intermediate files etc. Obviously it also does FTP etc too if you're so inclined.
I actually found this page whilst looking for a linux equivalent of ultraedit..
If you are more GUI-oriented and use one of the more newbie-friendly Linux distros like Ubuntu or Mint, this is another option and does not require any more installations.
You should have nemo as your default file manager. It may not be called "Nemo" on the menu, so go under Help > About of your file manager ("Files" app) to see.
In nemo, go to File > Connect to server, enter your remote machine's details (SSH's default port is 22), and then open the files just like any file on your local machine, with whatever editor you prefer. You can even close Nemo and continue working in your editor.
From the address bar, it seems to be using the sftp protcol.
Just be aware that if your remote host has an inactivity timeout for the SSH connection, this will also prevent you from saving changes in the editor after the timeout has dropped the connection...
Since sshfs is not supported in WSL at the moment, the tool that worked for me is sshfs-win.
Installation Steps
Go here and click "download winfsp"
Install it
Go here and download the installer
Install it
Open windows explorer and right-click "This PC" > "Map Network Drive..."
Select a drive letter (B:), type in "\\sshfs\debian#10.13.100.36" and click Finish
Boom, done. Now you can have a B: drive on your computer and just do whatever with those files. Open them with VSCode, delete them, whatever you like
If you work in IntelliJ IDEA, you can use Friendly Terminal plugin instead of the native terminal. It allows to open and edit remote files in IntelliJ IDEA editor. Video