it's possible to use vagrant to setup a environment for php development with some tools like PHP_CodeSniffer, PHP Mess Detector, etc, and then use sublime text plugin sublime-phpcs in the host machine to use this tools from vagrant?
I wanted to avoid install all this tools in my Host machine(mac os) but still use the sublime text with the plugin to develop in the host machine.
Thanks!
Technically you could probably point the sublime-phpcs plugin to an executable bash script which could run PHP on the VM through SSH. Something like this lets you run your VM's PHP:
ssh -i '/path/to/vagrant.pem' vagrant#vmip php
Where vagrant.pem is the SSH key that comes with vagrant.
It would also need to convert the local file path into a path that the VM could actually reach locally as well - either that or perform a reverse SSH connection back to the host.
In the end it's probably going to be very complicated and you might just be better off installing PHP locally.
Related
I am very much new to Perl. I am told to write a script where I have only the IP address of the remote machine. I tried to ping the machine through the IP address as :
$retval=system("ping xxx.xxx.x.xxx");
if ($retval==0) {
print "It pings\n";
} else {
print "ping failed\n";
}
Now I want to know the version of the Operating System in that machine (xxx.xxx.x.xxx) whether it is a WindowsServer 2019 or any Linux flavors with its version.
Want to know the version of Database whether that machine has Oracle or MySql with its version.
Want to know whether it has Weblogic Server or IIS server installed in it and if installed what is its version.
I want the name of the OS and its version and the name of the DB and its version along with the server version to be saved in a file.
Can someone please help me to achieve this successfully using the Perl Script?
Thanks in advance.
Rather than using an external program like ping, you should consider using the Net::Ping module that is a standard part of a Perl installation.
From the synopsis:
use Net::Ping;
$p = Net::Ping->new();
print "$host is alive.\n" if $p->ping($host);
$p->close();
As for getting more information, I second the suggestion of using Net::OpenSSH. In comment, you say that you can't use that as it's not installed on your remote systems, but I think you misunderstand how it works. The module only needs to be installed on your local system. The remote systems just need an ssh server.
Alternatively, you could look at Net::SNMP or Nmap::Parser.
In order to get the version of a remote OS, i guess you don't have much solutions than either :
using a scanner (e.g. nmap) that could do a TCP scan that could "probably" send you the OS name/version back (there's probably Perl modules to do that, but you can also throw regular system commands through perl to do that
connect to the machine remotely (using a supported protocol on that machine such as SSH or similar, depending on the OS..) and run system commands (such as 'uname' on *nix machines) to get the OS version.
using this method you can also gather anything else (database, middleware etc.)
but this implies that you know how to connect to the other machine (and that you know the OS.. in general).
I do not understand the uses for the commands ssh or git-clone in the rhc tool. If I try to connect via ssh I have to use a client like PuTTY and if I like to clone a project I have to use the GitBash on Windows. My question is, when I use the commands above?
You can use those commands if you have an ssh client, or git client that is accessible via your command line in windows. So if you can open up your cmd prompt, and type "ssh" or "git" and it works, then you can use the rhc ssh, and rhc git-clone commands. Mostly they are useful for Unix, Linux, and OS X, but with some configuration you should be able to do it from windows also.
I currently have an html file on a remote unix server that I ssh to. I have been using SFTP to constantly transfer it to my local machine to view it after my edits, but I am tired of this.
What is the best program/method for Mac users to have a browser window view of the html file that is stored in a remote unix server? Or is there an ssh client that can easily edit html files?
It is possible, but with some playing around on the server.
Once you have ssh'ed into the server, install a web server in that box.
Say the file is named index.html, you should make it available at the URL http://localhost:8000/index.htmlor port number can be anything.
The simplest method I can think of starting a web server at that location is
cd /directory/where/html/is/present
python -m SimpleHTTPServer 8000 # For python 2
python3 -m http.server 8000 # For python 3
This works provided python is installed on the server. It should not be that hard to install it as python is available from almost every package manager in every flavor of linux.
Now that html is available at python
http://localhost:8000/index.html
on that machine.
But we have not yet configured the browser in such way.
To do that you need to ssh into the server again, but with a -D option this time
ssh servername -D 7000
-D specifies application level tunneling when connecting via ssh
Then in Firefox, preferences/options -> Advanced -> Networks -> Connection Settings -> Choose Manual Proxy configuration
SOCKS HOST should be localhost , port no 7000.
Then the html should be directly available at
http://localhost:8000/index.html
in your Firefox browser.
This feature is only available in the Firefox browser.
You can mount the remote directory with sshfs which gives you easy access to all the files.
E.g.:
sshfs user#server:/directoryToMount /localDirectory
Is there anyway I can use PHPStorm to sync with my EC2 box through SCP? EC2 requires a private key to connect to it. I don't see any option for SCP in the deployment configuration section
SCP is file transfer over SSH, a newer version of which is SFTP. Both just work over SSH, if your server is accessible over SSH then these are the options you have. You're simply looking for the SFTP mechanism in PHPStorm with Auth type of "Key pair".
If you're looking for ES2 deployment integration, check Amazon EC2 plugin. It is compatible with current latest version of PHPStorm. Аmong other features, it provide SSH client allowing connections to EC2 instances.
Installation:
Download latest plugin version.
In PHPStorm open Settings (by default Ctrl+Alt+S). Then Plugins -> Install plugin from disk.
there is a plugin called source sync https://plugins.jetbrains.com/plugin/7374?pr= it might help you. or you may use SCP.
I tried with Phpstorm 3 without success but with the most recent version the ssh connection is working fine.
I was able to have the ssh connexion with the version Webstorm 2018.3
Where does hudson CI get user to run the cmd.exe ?
I'm trying to start and stop some remote services on various slaves and special credentials that are different than what hudson is using are needed. I can't find a place to override the user. I've tried running the server as various users, but it doesn't change anything.
Any other ideas?
Since you want to start and stop the services on the remote machine you need to login with these credentials on the remote machine, since I haven't found a way to start and stop a service on remote machine.
There are different ways to do that. You can create a slave that runs on the remote machines with the correct credentials. You can even create more than one slave for the same machine without any issues, than you can use different credentials for the same machine. These can then fire up the net stop and net start command.
You can also use the SSH plugin. This allows you to configure pre- and post-build ssh scripts. You 'just' need and ssh server on the windows machine. The password for the connection will be stored encrypted.
Use a commad line tool. So far I haven't found a Windows on board tool to have a scripted login to the remote machine. I would use plink for that task. plink is the scripted version of putty. Putty supports different connection types. So you can also use the build in telnet service (not recommended since telnet does not encrypt the connection). Disadvantage is that you will have the password unencrypted in the job configuration.
We had a similar problem, and I resorted to using PsExec. To my advantage, our machines exist on a separate LAN, within 2 firewalls, so I was OK with unencrypted passwords floating around. I had also explored SSH w/ Putty, which seemed to work, but not straightforward.
If someone can help with single line runas command, that could work too.
You don't say how your slaves are connected to Hudson, but I'll assume it's through the "hudson slave" service, since that's probably the most popular way to connect Windows slaves.
If so, the CMD.EXE is run with the same permissions as the user running the service. This can be checked by:
1. run services.msc
2. double-click hudson-slave service
3. go to Log On tab
By default, the slave service runs as "LocalSystem", which is the most powerful account on the system. It should be able to do whatever you need it to do. (i.e. start/stop services)