EzDevInfo.com

remote-access interview questions

Top remote-access frequently asked interview questions

Text editor for editing files over ssh [closed]

I can't find any free programmer-oriented text editor that would run on windows and would edit remote files over ssh(sfpt). Any suggestions?


Source: (StackOverflow)

C# Command Run remote System

I have to Run a command in Unix System from my C# Application running on Windows. The two system is in same network and I have all the required credentials.

Is there is any API from which I can run "ls" command of UNIX from C# code by establishing a SSH connection.

EDIT: I am looking for a solution which will help in running any command or script present in Remote System.


Source: (StackOverflow)

Advertisements

Mysql adding user for remote access

I created user user@'%' with password 'password. But I can not connect with:

mysql_connect('localhost:3306', 'user', 'password');

When I created user user@'localhost', I was able to connect. Why? Doesn't '%' mean from ANY host?


Source: (StackOverflow)

Using Emacs server and emacsclient on other machines as other users

I know that after I call (start-server) inside an existing Emacs session I can then use emacsclient -c (on the same computer) to create new frames that connect into that server, so that each new frame created by emacsclient has access to the same set of shared state (e.g. buffers).

Most of the documentation I've found focuses on the "give me fast access to my local Emacs" use case, and so there are two things that I haven't seen any details of yet:

  1. Can emacsclient -c access Emacs servers started by other users, or is it hard-wired to detect only sessions started by my own user?

  2. Does Emacs server (directly or indirectly) support remote connections? That is, is there some way to set up Emacs (possibly involving SSH) that allows calls to emacsclient -c on remote machines to have access to the local state of my Emacs server?

(In case you haven't already guessed, what I'd ultimately like to do is combine the two techniques above to provide rudimentary collaborative editing support.)


This is a real-world problem, so here's what I'm working with:

  • The necessary functionality should be built into Emacs already (23.3.1, 64-bit). I can stretch to Emacs extensions from the standard Ubuntu repositories, but I'd prefer not to. (Which I believe rules out Rudel, sadly.)
  • No new users or user spoofing. Solutions should work with the existing set of user accounts, and users must not pretend to be other users (e.g. via su or ssh).

If it makes any difference, the machines are on a private LAN, have OpenSSH clients and servers installed (and running), and all users can connect to (their own account on) all machines, but they have no shared filesystem.


So, does anybody know whether Emacs server can

  • grant access to other users, or
  • provide remote access?

EDIT

As commented in rwb's answer, it's clear that the new windows being opened locally by running emacsclient -c are actually being created by the remote Emacs server process. That is, emacsclient is simply triggering the relevant behaviour in the server. This causes some issues with incorrect display settings, since the server does not normally have access to the local desktop (see below). However, I can now connect in to a remote Emacs session if I use the following sequence of commands:

In one terminal, where 1.22.333.44 is the IP address of remotehost:

ssh -t -X remotehost \
  "emacs -nw --eval
   '(progn (setq server-host \"1.22.333.44\" server-use-tcp t) (server-start))'"

Then in another (on the same machine):

scp remotehost:.emacs.d/server/server /tmp/server-file
DISPLAY=localhost:10 emacsclient -c -f /tmp/server-file

The emacsclient command causes the remote Emacs server (which it finds details of in /tmp/server-file) to open up a graphical Emacs window (on the local display) that shares state with the Emacs session on the remote host.

Since the remote Emacs server was started via ssh -X, SSH provides it with access to my local display via a "fake" :10 display. The DISPLAY=:10 passed to it (via emacsclient) thus causes a window to be opened on my local desktop.


Although the approach above does tick the "Run Emacs server on remote machine, connect to it using emacsclient locally" box, it's very limited. In fact, it's not much different to running the server and clients all locally as a single user: the only difference is that the server is now remote, so has access to different system resources.

Unfortunately, launching via ssh -X is the only way I've been able to successfully open a window on a different machine's X server:

  • Specifying a basic DISPLAY=remote:0 gets nowhere (since Ubuntu X servers are started with the -nolisten tcp option).

  • Connecting via SSH and then using DISPLAY=:0 also fails, but this time only due to lack of suitable authentication credentials. (I believe that's the case, anyway: the error message cryptically says No protocol specified / Can't open display.)

I think that finding a way around the second problem would probably get me a good deal closer to a solution.


Having read the posts at http://comments.gmane.org/gmane.emacs.devel/103350 (starting at the '25 Oct 14:50' post, about half way down) I'm starting to wonder if this might be one of the rare things that Emacs cannot do (i.e. is impossible ;-) ).

However, if anyone does have a way to provide access to remote X displays without the permissions error above, I'm still open to persuasion....

TL;DR

As pointed out by rwb's answer, my questions above about whether Emacs can grant remote access have got things backwards. There's no real problem with Emacs granting access to other users (server-use-tcp and a suitable server-file take care of this): rather the problem is how to allow a process on one machine to open new X windows on other users' X displays (specifically, the Emacs running (start-server) needs to open windows for users who ask it to via emacsclient -c). That answer's beyond the scope of this question.

Alternative solution

As a workaround, we use the following:

  • machine0: tmux -S /tmp/shared-tmux-socket new-session
  • machine1..machineN: ssh -t machine0 tmux -S /tmp/shared-tmux-socket attach

with suitable file permissions on /tmp/shared-tmux-socket.

Then we run a text-mode Emacs in the shared terminal. :-) This does raise some user-spoofing questions, but at least the host can see everything that the guests are doing.


Source: (StackOverflow)

Use SQL Server Management Studio to connect remotely to an SQL Server Express instance hosted on an Azure Virtual Machine

Initial Attempt

I have a Azure VM with Windows Server 2012, on which I just installed SQL Server 2012 Express Database Engine component. Then, I followed the instructions here to connect remotely with SQL Server Management Studio.

  1. Create a TCP endpoint for the virtual machine
  2. Open TCP ports in the Windows firewall
  3. Configure SQL Server to listen on the TCP protocol
  4. Configure SQL Server for mixed mode authentication
  5. Create SQL Server authentication logins
  6. Determine the DNS name of the virtual machine
  7. Connect to the Database Engine from another computer

After step seven I received the following error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)

What else do I need to configure before connecting remotely?

Troubleshooting

I have been following the troubleshooting instructions here. Each block-quote below is a step described that that link.

Confirm the instance of the SQL Server Database Engine is installed and running.

Done. We installed SQL Server Express, and it is running as a named instance called SQLEXPRESS.

If you are attempting to connect to a named instance, make sure the SQL Server Browser service is running.

Done. We followed the steps here to turn on the SQL Server Browser service.

Get the IP Address of the computer.

Done. We will use these later for testing connectivity and maybe for setting up a static port for SQLEXPRESS.

10.241.62.155

fe80::45c:8c29:e19f:f78b%15

Get the TCP port number used by SQL Server.

Done. The SQL Server Management Studio server logs showed that the server was listening on port 49169.

Enable Protocols

Done. We had already enabled TCP/IP in the configuration manager, but we restarted the SQL Server Service just in case.

Testing TCP/IP Connectivity

Done. We used tcping.exe to test connectivity (cmd ping doesn't work easily with Azure.) We were able to connect to port 80.

  • tcping.exe buddha.cloudapp.net > successful
  • tcping.exe buddha.cloudapp.net 80 > successful

Testing a Local Connection

Done. We used sqlcmd.exe from the command prompt, and were able to connect locally via TCP with a username and password.

  • sqlcmd -S Buddha\SQLEXPRESS (success via shared memory protocol)
  • sqlcmd -S tcp:Buddha\SQLEXPRESS (success via TCP)
  • sqlcmd -S tcp:Buddha\SQLEXPRESS -U sa -P (success via TCP with username)
  • sqlcmd -S tcp:10.241.62.155\SQLEXPRESS -U sa -P (success with internal IP)

Opening a Port in the Firewall

We opened the port on which we SQLEXPRESS listens. The server logs (above) showed that SQLEXPRESS was actually listening on port 49169, but this is just one of many dynamic ports, and we wanted to set up the static port 1435.

  • Use WF.msc to create an inbound TCP rule for port 1435.
  • Use Azure Management Portal to create a TCP endpoint for port 1435.

The troubleshooting instructions also say:

If you are connecting to a named instance or a port other than TCP port 1433, you must also open the UDP port 1434 for the SQL Server Browser service.

Since we are connecting SQLEXPRESS (a named instance), we needed to open port 1434 for UDP.

  • Use WF.msc to create an inbound UCP rule for port 1434.
  • Use Azure Management Portal to create a UDP endpoint for port 1434

Further research about connecting to named instances revealed dynamic port issues. This is why we are using port 1435 (static) instead of port 49169 (one of many dynamic options.)

Instances of SQL Server Express, SQL Server Compact, and named instances of the Database Engine use dynamic ports. To configure these instances to use a specific port, see Configure a Server to Listen on a Specific TCP Port (SQL Server Configuration Manager). and here.

Done. We went to SQL Configuration Manager > SQL Server Network Configuration > Protocols for SQLEXPRESS > TCP/IP, we did the following.

Protocol Tab > Listen All > NO.

IP Addresses Tab > for each listed address

  • Enabled > Yes
  • TCP Dynamic Ports > Blank (delete the zero)
  • TCP Port > 1435 (or your choice)

After restarting the SQLEXPRESS service, we again looked in the SQL Server Management Studio logs, and found that the Server is Listening on port 1435!!! Hooray!

Testing the Connection

Done. We opened SQL Server Management Studio on our local (non-Azure) computer and connected.

  • buddha.cloudapp.net,1435 OR buddha.cloudapp.net\SQLEXPRESS
  • sa
  • password

Success.


Source: (StackOverflow)

Sublime Text 2 is sluggish during work over sshfs

I am using Sublime Text 2.0.1, and unfortunately making it work with files distributed over sshfs is a pain - switch to other tab and go back makes Sublime checking if file has not been changed.

Are there any Sublime preferences or maybe sshfs mount options which can make my work over remote resources possible?

For now I am using following sshfs option (faster encryption):

-o Ciphers=arcfour

Source: (StackOverflow)

Accessing localhost WCF from other device?

I've successfully created a WCF service that works how I want it to. The only problem is that I can not access the web service from anything but the actual machine the WCF service is running.

I understand that the Cassini web service is local only, I want to be able to run the WCF service on my customers system whenever they need the service in my desktop application.

Does anyone know of an easy way to do this without the customer installing anything more than the .NET Framework?

Thanks


Source: (StackOverflow)

Solution for using Sublime Text to edit files on a local server I created with vagrant? [closed]

I have a headless Ubuntu server created with vagrant and normally use vagrant ssh to access and then mess around with the files.

I need to edit the files, and I'm not terribly keen on learning vim/emacs, so I'm wondering if I can use my editor of choice (Sublime Text 2) to edit the remote files.

How would you recommend I go about this? I've heard many solutions, FTP, rsync, vim/emacs, etc. but I'm not sure for my particular situation (Sublime and vagrant) what I would be best off doing.


Source: (StackOverflow)

how to run node js remotely

I am running node using putty. but it doesn't work when putty session expire. How can I start node js permanently, should not be terminated if putty session end.


Source: (StackOverflow)

Developing PHP with Eclipse on a remote server (FTP) on Windows

I'm a real klutz when it comes to Eclipse, but I'm also poor, which is why it is the option I've chosen.

I've installed Eclipse 3.5, Eclipse for PHP, and RSE. I've actually gotten to a point where I can create a new (local) project and download all files to my local (Windows) computer. I'm not running any kind of web server on my local box, and am hoping to keep it that way for now.

I've imported my remote folder into my local project, where I can see all my PHP files and edit them. But of course, when I save, it just saves the local copy. Is there no "put" command? Can I not save straight to the server? Or perform an immediate sync of that one file? I certainly wouldn't want to have to perform a complex sync operation after every little incremental change.

I have no idea what RSE really is, nor how it works, and the documentation is, well, cloaked at best, non-existent at worst. Does anyone have some tips for me? What should my workflow be (barring any local server to test)?

Ideally, I would love to be able to open up the entire "project" directly from its location on the remote server and avoid dealing with a "local" copy altogether. Failing that, I would be willing to "get" the entire remote site once, and then manually "put" individual files that I change locally back, provided it's not a cumbersome process. Am I asking too much? Dreamweaver operates this way, but it's support for PHP is limited at best and can't be considered a full-fledged IDE...


Source: (StackOverflow)

How to remotely control a Windows Service with ServiceController?

I'm trying to control Windows Services that are installed in a remote computer. I'm using the ServiceController class.

I have this:

ServiceController svc =  new ServiceController("MyWindowsService", "COMPUTER_NAME");

With this, I can get the status of the Windows Service like this:

string status = svc.Status.ToString();

But I can't control the Windows Service (by doing svc.Start(); or svc.Stop();). I get the following exception:

Cannot open Servicexxx service on computer 'COMPUTER_NAME'

That's normal, I suppose there is something to do with access permissions. But how? I've looked into Google but didn't find what I was looking for. However I often read something related to impersonation, but I don't know what that means.

NB: The local and remote computers are both running Win XP Pro.

Thanks.


Source: (StackOverflow)

How do I pass credentials to a machine so I can use Microsoft.Win32.RegistryKey.OpenRemoteBaseKey() on it?

This .NET API works OK if I'm trying to open the Registry in a machine that's in the same domain as I am (and my logged-on user has admin rights on the target machine).

It gets tricky if it's an out-of-domain machine with a different, local administrative user (of whom I do have the password).

I tried to use WNetUseConnection() (which has served me well in the past in situations where what I wanted was to read a remote disk file) prior to calling OpenRemoteBaseKey(), but no dice -- I get an access denied exception.

Clearly, I must pass credentials some other way, but how?


Source: (StackOverflow)

Unable to connect to SQL Server instance remotely

I’m trying to access the SQL Server instance on my VPS from SQL Server Management Studio on my local machine. It’s not working (the error I’m getting is:

“A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.”

I think this is because I need to configure the database engine to allow remote connections (correct me if I’m wrong!). So I’ve found this step-by-step guide to help me do that: http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/ I’ve got to point 10 in the guide and I am now stuck! I don’t have SQL Server Management Studio installed on my VPS. Anyway, this has left me with two options:

  1. Install SSMS
  2. Find another way to do point 10 onwards in the guide without having SSMS installed

I tried installing SSMS on my VPS using the Web Platform Intaller but it keeps failing. I don’t know why it’s failing because it doesn’t seem to give a reason why. Does anyone know how I could allow remote connections a different way?

The version of SQL Server installed on my VPS is SQL Server 2008 Express R2.

Update: I have tried to disable the firewall on both my laptop and VPS to see if it is a firewall issue. This made no difference to the error message.

Another Update: Having now been able to install SSMS (I installed directly from the website rather than using the WPI), I have been able to check that the server is configured to allow remote connections (I went to SSMS, connected to the SQL Server instance, right-clicked on the connection, clicked Properties, went to the Connections tab. "Allow remote connections to this server" is already ticked).

SOLUTION Thanks to everyone for helping me get to this solution! I've finally managed to get it to work! I followed Filip De Vos's advice and opened the ports in the Firewall on my VPS and then I received a different error message. This led me to investigate further and I found that I was using the wrong credentials to login! So I've set a password for the sa user and I've managed to login using that! Thanks again!


Source: (StackOverflow)

Where does rsync keep the log file for complete and incomplete data transfers?

I want to get the IPs of all the destination devices where my data transfer using rsync could not be complete (or even start) as those devices are not connected to Internet or got disconnected while data transfer ...


My actual problem scenario is :

rsync -t Desktop/sony.pdf home@a.b.c.d: ssh: connect to host a.b.c.d port 22: No route to host

and I want the list of all such IPs where the data transfer could not be complted ...

the list of all IPs like 'a.b.c.d '


Source: (StackOverflow)

best practices for "data layer" in android client apps

Here is one design/ best practices question..

I'm new to android development, and basically new to web/mobile solutions.

So, my question is - what are best practices when organizing structure of android application that get data from the remote server?

Should request to server go into one class that does communication with server (get and post requests), or should I look at my requests as data source, meaning that every data class manages it for itself?

or should I have more levels of abstraction - one level for acquiring data, other for model that uses some interfaces without knowing from what source data come from?

I'm curious how experienced android developers approach to these design issues...


Source: (StackOverflow)