Raising the nofile limit under WSL2 [closed] - config

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I'm not what you would call an advanced linux user, so my apologies for a probably dumb question.
I'm trying to raise the NOFILE limit for my UBUNTU 20.04 distro using WSL2, following this guide: cannot-increase-open-file-limit-past-4096-ubuntu
However, when I try to modify the corresponding .conf files I get a permision denied error.
When trying to do so from windows and VsCode I get:
Failed to save 'system.conf': Command failed: "C:\Users\sague\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd" --file-write "c:\Users\sague\AppData\Roaming\Code\code-elevated-mjlcag" "\\wsl$\Ubuntu-20.04\etc\systemd\system.conf" Error using --file-write: EPERM: operation not permitted, open '\\wsl$\Ubuntu-20.04\etc\systemd\system.conf'
And when trying to do so using nano within the WSL2 terminal (using windows terminal) I get:
Error writing /etc/systemd/system.conf: Permission denied
Please help, I'm stuck with this :')
My apologies for what is probably a very noob question

Well, to be honest you are making a few newbie mistakes, but don't worry - Even once you get past those, what you are trying to do under WSL isn't easy.
First, you are trying to edit a system file as a normal user in nano, resulting in Permission denied. Solution: Use sudo nano /etc/systemd/system.conf instead. But see below (3) for why this ultimately isn't going to work.
Second, you are trying to edit a WSL system file as a normal user under VSCode. This just won't work since VSCode always runs as the normal user by design. It may be possible to get it to run under sudo, but it's probably not worth the effort. Note that this is also a limitation when running the "Remote - SSH" extension in VSCode (similar to the "Remote - WSL" one you are using now).
You are trying to modify the systemd configuration under WSL, where there is no systemd support, so even when you do successfully edit the file, it isn't going to do anything.
Your next attempt once you got past that would probably be (as it is for most of us) to try to raise the ulimit through /etc/security/limits.conf, which is the right way to do it, but requires a trick under WSL. That file is a PAM construct, and ... well, PAM runs at login, and we don't "login" in WSL, so PAM usually doesn't get called.
The hacky solution, as I cover in this answer on Ask Ubuntu (with great assistance from a number of answers in this Github thread) is to make the modifications to /etc/security/limits.conf and then to force PAM to process it by sudo'ing back in as your own user via:
sudo su $USER
or possibly
sudo su - $USER # if you need to run as a login shell
There are also some other suggestions in the Github thread, if those incantations don't quite work for you.

Related

Unkown permission issues preventing wsl2 from accessing random windows files/directories [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I'm having permissions issues when accessing seemingly random directories/files on the windows filesystem with wsl2/ubuntu. Some directories are not accessible and I get a 'permission denied' error when I try to access them or any of the files in them. However, I have no issues accessing them from Windows itself through explorer or a non-admin powershell or command-line shell.
From the WSL side I am the owner of the files and directories and have correct permissions but I still cannot access them. I can however access these directories/files if I switch to root. I shouldn't have to though since the permissions on this directory are the same as the ones on other directores.
drwxr-xr-x me me
I've tried looking at the directory properties from the Windows side and making them more permissive ("Full-control" to each group in the properties>security menu) to all of the various groups with no success. I am the only user of this computer and the only groups that exist are...
Authenticated Users
SYSTEM
Administrators (${my-machine-name}\Administrators)
Users (${my-machine-name}\Users)
I can provide more info if needed.
Make sure that not only the directory that contains the files has rx for your WSL user but also every directory above it (Sorry, would have commented but I don't have enough rep yet).
Try creating a /etc/wsl.conf with the following:
[automount]
options="metadata,uid=1000,gid=1000,umask=022"
After creating the file:
Exit your WSL session
wsl --terminate <distro> or wsl --shutdown
Then restart and test the file/directory permissions again.
The uid and gid probably already default to those values since you mention that the files and directories on the NTFS drive are showing as owned by your user. So they can probably be left out.
The metadata option is important, as it allows WSL to map Linux permissions on to files and directories created in WSL on those NTFS drivers. But again, this isn't really your problem here either.
The umask is hopefully the long-term answer to your problem, as it will map WSL/Linux rwxr-xr-x to directories created in Windows, and rw-r–r– to files.

Copying files from server to local computer using SSH [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I am having trouble copying files from a remote server using SSH. Using PuTTY I log in to the server using SSH. Once I find the file I would like to copy over to my computer, I use the command:
scp username#host.com:/dir/of/file.txt \local\dir\
It looks like it was successful, but it only ends up creating a new folder labeled 'localdir' in the remote directory /dir/of/.
How can I copy the file to my local computer over SSH?
It depends on what your local OS is.
If your local OS is Unix-like, then try:
scp username#remoteHost:/remote/dir/file.txt /local/dir/
If your local OS is Windows ,then you should use pscp.exe utility.
For example, below command will download file.txt from remote to D: disk of local machine.
pscp.exe username#remoteHost:/remote/dir/file.txt d:\
It seems your Local OS is Unix, so try the former one.
For those who don't know what pscp.exe is and don't know where it is, you can always go to putty official website to download it. And then open a CMD prompt, go to the pscp.exe directory where you put it. Then execute the command as provided above
EDIT
if you are using Windows OS above Windows 10, then you can use scp directly from its terminal, just like how Unix-like OS does.
Thanks to #gijswijs #jaunt #icanfathom
Your question is a bit confusing, but I am assuming - you are first doing 'ssh' to find out which files or rather specifically directories are there and then again on your local computer, you are trying to scp 'all' files in that directory to local path. you should simply do scp -r.
So here in your case it'd be something like
local> scp -r username#host.com:/path/to/dir local/path
If youare using some other executable that provides 'scp like functionality', refer to it's manual for recursively copying files.
You need to name the file in both directory paths.
scp username#host.com:/dir/of/file.txt \local\dir\file.txt
Make sure the scp command is available on both sides - both on the
client and on the server.
BOTH Server and Client, otherwise you will encounter this kind of (weird)error message on your client: scp: command not found or something similar even though though you have it all configured locally.
that scp command must be issued on the local command-line, for putty the command is pscp.
C:\something> pscp username#host.com:/dir/of/file.txt \local\dir\

What is the difference between bin/sh, bin/bash, sbin/nologin, bin/tcsh, etc? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am new to linux so please go easy and talk slow =)
In Plesk I have some options for accessing the server over SSH. I just want to connect, add my public key and run rsync for backup.
What is the difference between these options?
Which option should I choose?
What are these? They look like directories to me.
Access to the server over SSH:
/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/ksh
/bin/bash (chrooted)
/bin/rbash
Here is an image of the Plesk control panel:
Use /bin/bash
What are these? They look like directories to me.
These are different options for default shell given to users who connect via SSH
If you haven't used any of these shells before, I think bash is the best option for you. Most tutorials and articles for linux commands online assume you are using bash.
However, you have two options for bash: /bin/bash and /bin/bash (chrooted).
To do backups, you will probably need the bash to have full access to execute all commands.
I'm not sure whether you can get what you want done with a chrooted bash.
Basically, chrooted bash is for avoiding mishaps.
To know more about chrooting, you can read this article
Most of options are various Unix shells. A shell is basically what interprets the text that you type in the window. Some people prefer one shell over others. If you are not familiar with any shell in particular, pick one based on your needs Comparison Chart
If you don't know, you should use /bin/bash. It's the most popular, and will be the easiest for you to get help using. That said, they all do the same thing, just in slightly different ways.

automatic ssh session when moving to mapped sshfs [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
If you have a network drive mapped via sshfs, is there a way to automatically log on via ssh whenever changing to that directory?
$USER:$LOCALHOST:~: sshfs $USER:$REMOTEHOST /Volumes/dev0
$USER:$LOCALHOST:~: cd /Volumes/dev0
$USER:$REMOTEHOST:~
Thomas Jansson provides a guide on integrating sshfs with autofs. I'll summarize his guide here, so this answer will still be worth something if his site ever goes offline:
Create an /etc/auto.master:
/mnt/sshfs /etc/auto.sshfs uid=1000,gid=1000,--timeout=30,--ghost
Make sure your uid and gid match your userid and guid in /etc/passwd or whatever you use to provide system accounts.
Now add lines into /etc/auto.sshfs, one per desired filesystem, in the following form:
bar -fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536 :sshfs\#tjansson#bar.com\:
Be sure to change tjansson#bar.com to whatever user account and hostname you're going to be using. Change the leading bar to whatever you'd like the directory to be named. When you cd /mnt/sshfs/bar, autofs will automatically mount the FUSE filesystem for you. Of course, using SSH keys and the ssh-agent(1) will make this far more pleasant.
Update
... create a directory that literally logs you into the other machine.
Hey, that's pretty clever idea. You could either write a shell function that checks the directory name you want to cd into and start a new ssh for you. Maybe you can (ab)use the PROMPT_COMMAND variable to ssh to the host if the directory name matches. Be warned that either approach will slow down your normal cd or every prompt display.
Another approach that I've used and enjoyed is a small little helper script, ~/bin/ssh-to:
#!/bin/bash
hostname=`basename $0`
ssh $hostname $*
Symlink new names to this shell script: ln -s ssh-to sarnold.org and then you can run a command or log in on a remote site without typing the ssh all the time:
sarnold.org python foo.py
It'll log you in to whatever machine you've used for the name of the symbolic link and run whatever command you give it.

Alternative SSH Application to Plink [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I have recently started having problems with TortoiseCVS, or more specifically with plink, the SSH application that comes with it. The IP address it tries to connect to can not be changed and is stuck with the old CVS repository's IP. Downloading plink from it's home site and calling from the command line still has this problem.
TortoiseCVS has the option to choose the SSH application it uses and I was wondering which other alternatives there are that I can use instead?
Are you sure this is a problem with plink? It sounds to me like you have CVS/Root files lying around that still point to the old cvs ip address. In general, CVS doesn't make changing repositories into a fun process. Since you are using Windows, if you install WinCVS with macros support (Python module loaded) it has a macro that can be used to mass change CVS roots.
Otherwise, its up to you to script the process.
FWIW, I've used plink quite a bit and never had a similar problem.
Putty is probably the best SSH client out there:
http://www.chiark.greenend.org.uk/~sgtatham/putty/
I'd recommend you stick with PuTTY too. You might find it useful to run Pageant in conjunction with Plink to avoid having to type in the passphrase.
But if you want to research alternatives you should review this Wikipedia resource:
http://en.wikipedia.org/wiki/Comparison_of_SSH_clients
Thanks to jsight (and Mark Biek for pointing out the connection between plink and putty) I decided to investigate more fully.
It turned out that plink had been using the "Default Settings" stored Session that I set up for putty and wasn't allowing them to be overridden.
edit:
The Geek: Also, this is a good example why you should always, always use DNS/hostnames instead of the IP address directly.
The problem was nothing to do with the IP address change, and in this case the DNS changed as well. I can see your point, but this isn't the 'good example' you are looking for.
For what it's worth, plink is just a command-line version of putty written by the same guy.
I think jsight probably has the right idea.
It might be worth trying Tunnelier from www.bitvise.com
TortoiseSVN, at least, has an option called Relocate which you can use if the location of the repository has changed.
Also, this is a good example why you should always, always use DNS/hostnames instead of the IP address directly.
I'm using TortoiseCVS 1.10.9 on Vista Business, and ext connections to my server were regularly crashing TortoisePlink.
I downloaded the latest puTTY (0.60) and set TortoiseCVS to point to the plink included with this puTTY (CVS->Preferences->Tools). The command line options appear to be the same, but one difference is that TortoisePlink pops up a password dialog if you don't have a keypair for your server. Regular plink does not. So you have to either create the keypair (puttygen, I believe) or specify a -pw on the command line options (very BAD security idea).
+1 for PuTTy... been using it for the last decade and never needed anything else!