Can I have remote ssh terminal access in PhpStorm? - ssh

I develop locally using PhpStorm, Git and VirtualBox on my local machine. I use Git to handle the process of moving work to staging or production environments. Currently I'm using MobaXterm (an excellent free tabbed ssh client for windows) to have terminal access to do things on staging and production servers. PhpStorm has a local terminal built in, but how would I use it to have multiple ssh terminal access? (This way I can have local, remote staging, and remote production terminal access all from within my IDE)

Figured it out!
On a fresh copy, PhpStorm will have Tools > Terminal to bring up the local terminal. To have additional ssh terminal access, this is what I did...
Setup servers
1.1) File > Settings > (Type: "Deployment" into the search box)
1.2) Hit the + button and fill in the necessary fields into the connection tab.
1.3) Click on the "Mappings" tab and clear the field "Local path"
since we will only be using the terminal.
1.4) Repeat Steps 1.2 and 1.3 for each server you want a terminal tab for.
1.5) Don't set any of these as default, so that you will be prompted to choose
a server in Step #2 below...
Start a remote terminal tab (this will also open up local terminal)
2.1) Tools > Start SSH session (this option doesn't appear until Step #1 is
completed)
2.2) You will be prompted to select a server from Step #1.
The terminal window appears and a new tab appears next to "local" in the
terminal window.
EDIT: (Thanks to Dan Dascalescu) you may want to also ensure the SSH Remote Run plugin is enabled. It's enabled by default in PhpStorm 8 (not sure about earlier versions).

PhpStorm has a plugin called "SSH Remote Run".
See also the built-in terminal.

Related

Remote Development SSH - No Linux Installation Found on the Selected Machine

I'm trying to connect SSH but it returns the error that there is no Linux installed on the machine on PhpStorm (IDE by JetBrains).
I use the Fedora 36 distribution. When I start the project via SSH through the remote field, it connects normally:
Now, if I try to create a new project only to connect and start working within the IDE itself according to the folders, it gives me the error that Linux is not installed on the machine:
Return error:
How can I manipulate the folders and codes of a project equally VSCode SSH extension? In SSH through the IDE itself as if it were a project from 0 ? Is it possible in PhpStorm?

No dropdown option of IntelliJ in IDE version of Remote Development using SSH in JetBrains Gateway

I am trying to connect to a remote server using JetBrains Gateway, so that I can use IntelliJ IDE for code changing purposes.
Both IntelliJ and JetBrains Gateway are -newly installed- on my device and I've rebooted my PC after installation as well.
I entered the hostname, password and it says that I'm "Successfully Connected".
But in the IDE version dropdown, nothing shows up even though I have IntelliJ installed on the system.
I do see the Other options... link. But the following options seem like they are to be used if no IDE is installed :
My Question is
How to get IntelliJ IDE (which is already installed) in the dropdown of JetBrains Gateway
You need to run a script to turn the server on
"The main script to run a remote IDE is remote-dev-server.sh, located in the bin subdirectory of your unpacked IDE"
From the Jetbrains instructions here

Need to restart wsl everytime after Windows start before using vscode-remote

I'm running Windows 10 with WSL2. I'm using VSCode with the Remote - WSL extension to open the files from my wsl file system.
When I boot my Windows laptop, and open VSCode I get the following error:
When I perform a wsl.exe --shutdown in PowerShell, and restart Docker Desktop, Everything works fine. But I have to do this after every laptop restart.
Remote WSL extension version: v0.51.4
Visual Studio Code version: v1.51.1
Windows version: 10.0.19041 Build 19041
Someone any idea?
I have had this problem several times, and I have found that on Windows 10 20H2 one of the two options described below solves the problem.
Network reset
This option can make you lose your network configuration, so use it with discretion and read every warning. You can perform this task by going to Settings > Network & Internet > Status. There you need to click on the option "Network reset" after that, you can start the network reset by clicking on "Reset now" Picture of Windows 10 20H2 status section. Then you will need to wait some minutes until your PC is restarted automatically and try to execute Visual Studio Code under WSL2 again.
Reset Windows
This option is dangerous as it will remove either all your files and programs or all your installed programs. You select what you want to remove before starting the reset process. This option can be performed by going to Settings > Update & Security > Recovery. Then you have to click on the button "Get started" on the section "Reset this PC" and follow the instructions provided by the reset tool Picture of Windows 10 20H2 recovery section. After your Windows is reset, you will have to configure your WSL again because all your WSL files will be lost when executing this operation.

How to install Terraria TShock Server on Ubuntu Server?

Recently I decided to install Terraria server on Ubuntu Linux, but didn't find any completed instructions, so I decided to make my own, to help pure Terraria fans like me. This arcticle is relevant on 15.02.2019.
So first of all, you need a dedicated server. I used vps server from Heztner guys, but you can use any kind of tech you want (like raspberry pi or old pc with Ubuntu Server installed. Just make sure its minimal configuration fits Terraria Server).
After you first powered up your device and created password, we'll install SSH to make our setting up process a little bit comfy. You will be able to access server with any other device, if you have ssh installed in cmd or terminal.
Windows 10
Has SSH preinstalled in cmd. So all you need to do is
Type ssh-keygen (it will ask you to point the folder to extract keys, you can do it or just press enter)
Type ssh-copy-id "username"#"yourdeviceip" (Example: root#116.23.106.75)(In username type root)
Enter root password and you're in ')
Ubuntu 18.04
You may need to enable SSH in terminal. Use this instruction. Process is the same as in cmd on Windows 10.
Also
You can use SSH clients like Termius, you just need to create new Host with enabled SSH and put your server ip. Then choose user and enter password, and you're in.
Finally we're done with SSH and begining to setup our working environment. To fully operate with our system, we need to install several programs, as
mono-complete (to emulate windows shell environment, so TShock can work properly)
screen (to detach our terraria server screen)
unzip
And finally our Terraria server
Installation
First we create different user, so we store Terraria files separately of root.
adduser terraria
Then add it to sudo group, so you can launch several admin commands
adduser terraria sudo
Then install programs
sudo apt-get install mono-complete screen unzip
Enter as terraria user
su terraria
Go to your home folder
cd
Download latest TShock file, for me it's 4.3.25. If there is newer version, just go to their github page and copy zip file download link and paste it instead of mine.
sudo wget https://github.com/Pryaxis/TShock/releases/download/v4.3.25/tshock_4.3.25.zip
Unzip it
unzip tshock_4.3.25.zip
Delete zip-file
rm tshock_4.3.25.zip
Execute server one time to create the map
mono-sgen TerrariaServer.exe (type it every time you want to launch the server)
And now, when the map created and launched, you simply press ctrl+a to start screen, and then press d. Now your screen is detached and you can use your console regardless of server. Also this wont let your Terraria process shut down because of inactivity.
Bonus level
And this part will be for people who want to transfer their local map to server. I did it because first time I played Terraria with friends through Steam, and then I created server so map can run 24/7.
All you need to do is create ssh connection from device you store your local map. If you did it previously, then go to your Steam folder, find Terraria worlds, right click, properties and copy the path. Then go to cmd and type
scp "yourworldpath" terraria#*yourserverip*:~
It will copy your local world to home section, then go back to your ssh with terraria user and type
cd
mv "yourworldname" .local/share/Terraria/Worlds/
That thing will move your world file to hidden .local folder, where all world files store. Aaaand that's all. Just go to number 8 and do it again. Hope this guide will help you:) If you find any mistakes or face with problems, just comment this section, so I can fix it.

How to get Sikuli working in headless mode

If we have a headless test server running sikuli (both ubuntu and windows configurations needed), how to get it work without a physical monitor and preferably for as many screen resolutions as possible.
I successfully got sikuli running in headless mode (no physical monitor connected)
Ubuntu: check Xvfb.
Windows: install display driver on the machine (to be headless) from virtualbox guest additions display drivers and use TightVNC to remotely set resolution from another machine.
Detailed steps for windows 7
Assume that:
Machine A: to be headless machine, windows 7, with vnc server ready (e.g. TightVNC server installed and waiting for connections).
Machine B: will be used to remotely setup the virtual display driver on machine A.
steps:
Download virtualbox guest additions iso file on Machine A from here (for latest version check latest version here and download VBoxGuestAdditions_x.y.z.iso)
Extract iso file (possibly with winrar) into a directory (let us call it folder D)
using command prompt cd to D folder
Driver extraction
-To extract the 32-bit drivers to "C:\Drivers", do the following:
VBoxWindowsAdditions-x86 /extract /D=C:\Drivers
-For the 64-bit drivers:
VBoxWindowsAdditions-amd64 /extract /D=C:\Drivers
Goto device manager
add hardware
Restart and connect with VNC viewer, now you should be able to change screen resolution
other valuable info on launchpad.
I got SikuliX working in a true headless mode in GCE with a Windows 2016 client system. It takes some duct tape and other Rube Goldberg contraptions to work, but it can be done.
The issue is that, for GCE (and probably AWS and other cloud environment Windows clients), you don't have a virtual video adapter and display, so, unless there's an open RDP connection to the client, it doesn't have a screen, and SikuliX/OpenCV will get a 1024x768 black desktop, and fail.
So, the question is, how to create an RDP connection without having an actual screen anywhere. I did this using Xvfb (X Windows virtual frame buffer). This does require a second VM, though. Xvfb runs on Linux. The other piece of the puzzle is xfreerdp 2.0. The 2.x version is required for compatibility with recent versions of Windows. 1.x is included with some Linux distros; 2.x may need to be built from sources, depending on what flavor Linux you're using. I'm using CentOS, which did require me to build my own.
The commands to establish the headless RDP session, once the pieces are in place, look something like this:
/usr/bin/Xvfb :0 -screen 0 1920x1080x24 &
export DISPLAY=:0.0
/usr/local/bin/xfreerdp /size:1920x1080 /u:[WindowsUser] /p:"[WindowsPassword]" /v:[WindowsTarget]
In our environment we automated this as part of the build job kicked off by Jenkins. For this to work under the Jenkins slave, it was also necessary to run the Jenkins slave as a user process, rather than a service... this can be accomplished by enabling auto admin login and setting the slave launch script as a run (on logon) command.
For those looking to automate on ec2 windows machines, this worked for me: http://www.allianceglobalservices.com/blog/executing-automation-suite-on-disconnectedlocked-machines
In summary, I used RDC to connect, put the following code in a batch file on remote desktop, double clicked it, and sikulix started working remotely (kicking me out of RDC at the same time). Note that ec2 windows machines default to 1024x768 when tscon takes over which may be too small so TightVnc can be used to increase the resolution to 1280x1024 before running.
tscon.exe 0 /dest:console
tscon.exe 1 /dest:console
tscon.exe 2 /dest:console
tscon.exe 3 /dest:console
START /DC:\Sikulix /WAIT /B C:\Sikulix\runsikulix.cmd -d 3 -r C:\test.sikuli -f C:\Sikulix\log.txt -d C:\Sikulix\userlog.txt
I just figure out a way to resolve similar issue.
My env:
local: windows pc
remote (for running sikulix + app I would like to test): windows ec2 instance
My way:
1.create a .bat file, its contents:
ping 127.0.0.1 -n 15 > nul
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
)
cd "\path\to\sikulix"
java -jar sikulixide-2.0.5.jar -r /path/to/sikulix -c > logfile.log
prepare your app
run the bat (right click > run as administrator)
ping will give your 10s, so that you can bring your app back to front
you will be disconnnected from rdp connection
Explanation:
ping is like "sleep"
for loop: kick out current user & keep session alive