Issue
I mean to get a terminal in an Ubuntu 20.04LTS server via ssh under PS 5.1 in Win 10. I know I can work with href="https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse" rel="nofollow noreferrer">native support for OpenSSH, and I have already done it before.
Now I want to do it without having admin rights, to minimize "tainting" my system. For reasons described below (1), I think I cannot work with native OpenSSH.
For reasons described below (2), I think it is possible. For instance, I can already start a session and issue remote commands ref, see below (3). But I couldn't start a terminal.
Is there a way to accomplish what I mean? How?
(1) Why, for my purposes, I cannot work with native OpenSSH?
For instance, the first two commands in the PS-way of enabling OpenSSH already require admin (my PS is in Spanish):
> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
Get-WindowsCapability : La operación solicitada requiere elevación.
> Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Add-WindowsCapability : La operación solicitada requiere elevación.
(2) Why I think it might be possible to get an ssh terminal without admin rights in PS?
Because I can already perform several similarly demanding actions as a regular user without admin rights, outside PS:
1.1. I can ssh from
Msys2
portable1.2. I can connect from
putty
(portable)1.3. I can transfer via
WinSCP
portableItem (3) below.
(3) How to start an ssh session and issue remote commands from PS
Install Posh-SSH
for the current user only.
Then
> New-SSHSession -Host xxx.xxx.0.xxx -Credential (Get-Credential)
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
Server SSH Fingerprint
Do you want to trust the fingerprint xx:xx:...
[] Y [] N [?] Ayuda (el valor predeterminado es "N"): y
SessionId Host Connected
--------- ---- ---------
0 xxx.xxx.0.xxx True
> Get-SSHSession
SessionId Host Connected
--------- ---- ---------
0 xxx.xxx.0.xxx True
> Invoke-SSHCommand -Index 0 -Command "pwd"
Host : xxx.xxx.0.xxx
Output : {/home/user1}
ExitStatus : 0
Solution
Windows 10 has SSH built in since v1809. An OpenSSH-Client is already installed, you can directly use it by calling ssh
. Try Get-Command ssh
. It should return C:\WINDOWS\System32\OpenSSH\ssh.exe
. You can connect to anything that supports SSH without administrative privileges "out of the box":
ssh -l <username> <DNS-Name/IP>
There is also an OpenSSH-Server available, but has to be enabled as a feature first. You probably need administrative privileges to enable that.
MS documentation on enabling OpenSSH-Server
Answered By - stackprotector Answer Checked By - Timothy Miller (WPSolving Admin)